File tree Expand file tree Collapse file tree 7 files changed +82
-18
lines changed Expand file tree Collapse file tree 7 files changed +82
-18
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ type Config struct {
5
5
Image ImageConfig `json:"image"`
6
6
Security SecurityConfig `json:"security"`
7
7
Network NetworkConfig `json:"network"`
8
+ Information Information `json:"information"`
8
9
}
9
10
10
11
type SecurityConfig struct {
@@ -25,3 +26,8 @@ type ImageConfig struct {
25
26
MaxImagesInCache int `json:"maxImagesInCache"`
26
27
ImageQuality int `json:"imageQuality"`
27
28
}
29
+
30
+ type Information struct {
31
+ Id string `json:"id"`
32
+ Name string `json:"name"`
33
+ }
Original file line number Diff line number Diff line change @@ -89,22 +89,25 @@ func readConfig() {
89
89
}
90
90
91
91
func getDefaultConfig () interfaces.Config {
92
- config := new (interfaces.Config )
93
-
94
- // image config
95
- config .Image .CacheExpiresInMillis = 10000
96
- config .Image .MaxImagesInCache = 100
97
- config .Image .ImageQuality = 512
98
-
99
- // application config
100
- config .Application .CacheExpiresInMillis = 10000
101
-
102
- // network config
103
- config .Network .Address = "0.0.0.0:3000"
104
-
105
- // security config
106
- config .Security .ExpirationInDays = 99
107
- config .Security .Secret = "authenticationCode"
108
-
109
- return * config
92
+ return interfaces.Config {
93
+ Image : interfaces.ImageConfig {
94
+ CacheExpiresInMillis : 10000 ,
95
+ MaxImagesInCache : 100 ,
96
+ ImageQuality : 512 ,
97
+ },
98
+ Application : interfaces.ApplicationConfig {
99
+ CacheExpiresInMillis : 10000 ,
100
+ },
101
+ Network : interfaces.NetworkConfig {
102
+ Address : "0.0.0.0:3000" ,
103
+ },
104
+ Security : interfaces.SecurityConfig {
105
+ ExpirationInDays : 99 ,
106
+ Secret : "authenticationCode" ,
107
+ },
108
+ Information : interfaces.Information {
109
+ Id : "rmtly" ,
110
+ Name : "rmtly" ,
111
+ },
112
+ }
110
113
}
Original file line number Diff line number Diff line change
1
+ package contants
2
+
3
+ const VERSION = "2.1.0"
Original file line number Diff line number Diff line change
1
+ package interfaces
2
+
3
+ type InformationResponse struct {
4
+ ID string `json:"id"`
5
+ NAME string `json:"name"`
6
+ URL string `json:"url"`
7
+ VERSION string `json:"version"`
8
+ }
Original file line number Diff line number Diff line change
1
+ package routers
2
+
3
+ import (
4
+ "encoding/json"
5
+ "github.com/gorilla/mux"
6
+ "net/http"
7
+ "rmtly-server/information/services"
8
+ )
9
+
10
+ const PREFIX = "/information"
11
+
12
+ func InformationRouter (router * mux.Router ) {
13
+ subRouter := router .PathPrefix (PREFIX ).Subrouter ()
14
+
15
+ subRouter .HandleFunc ("/" , func (writer http.ResponseWriter , request * http.Request ) {
16
+ bytes , err := json .Marshal (services .GetInformation ())
17
+ if err != nil {
18
+ writer .WriteHeader (http .StatusBadRequest )
19
+ return
20
+ }
21
+
22
+ _ , _ = writer .Write (bytes )
23
+ writer .WriteHeader (http .StatusOK )
24
+ }).Methods (http .MethodGet )
25
+ }
Original file line number Diff line number Diff line change
1
+ package services
2
+
3
+ import (
4
+ configService "rmtly-server/config/services"
5
+ "rmtly-server/contants"
6
+ "rmtly-server/information/interfaces"
7
+ )
8
+
9
+ func GetInformation () * interfaces.InformationResponse {
10
+ information := configService .GetConfig ().Information
11
+ return & interfaces.InformationResponse {
12
+ NAME : information .Name ,
13
+ URL : "" ,
14
+ ID : information .Id ,
15
+ VERSION : contants .VERSION ,
16
+ }
17
+ }
Original file line number Diff line number Diff line change 4
4
"github.com/gorilla/mux"
5
5
"net/http"
6
6
"rmtly-server/application/routers"
7
+ routers4 "rmtly-server/information/routers"
7
8
routers2 "rmtly-server/notification/routers"
8
9
routers3 "rmtly-server/security/routers"
9
10
)
@@ -28,6 +29,7 @@ func RootRouter() *mux.Router {
28
29
routers .ApplicationRouter (router )
29
30
routers2 .NotificationRouter (router )
30
31
routers3 .AuthenticationRouter (router )
32
+ routers4 .InformationRouter (router )
31
33
32
34
return router
33
35
}
You can’t perform that action at this time.
0 commit comments