File tree Expand file tree Collapse file tree 5 files changed +41
-12
lines changed Expand file tree Collapse file tree 5 files changed +41
-12
lines changed Original file line number Diff line number Diff line change 1+ package middlewares
2+
3+ import (
4+ "net/http"
5+
6+ "github.com/codeshelldev/secured-signal-api/utils/config"
7+ )
8+
9+ type ServeMiddleware struct {
10+ Next http.Handler
11+ }
12+
13+ func (data ServeMiddleware ) Use () http.Handler {
14+ mux := http .NewServeMux ()
15+
16+ mux .HandleFunc ("/favicon.ico" , func (w http.ResponseWriter , req * http.Request ) {
17+ http .ServeFile (w , req , config .ENV .FAVICON_PATH )
18+ })
19+
20+ mux .Handle ("/" , data .Next )
21+
22+ return mux
23+ }
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ func Create(targetUrl string) *httputil.ReverseProxy {
1111 proxy := httputil .NewSingleHostReverseProxy (url )
1212
1313 return proxy
14- }
14+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
1212 log "github.com/codeshelldev/secured-signal-api/utils/logger"
1313)
1414
15- var initHandler * httputil.ReverseProxy
15+ var proxy_last * httputil.ReverseProxy
1616
1717var ENV * config.ENV_
1818
@@ -31,26 +31,30 @@ func main() {
3131
3232 log .Info ("Initialized Logger with Level of " , log .Level ())
3333
34- initHandler = proxy .Create (ENV .API_URL )
34+ proxy_last = proxy .Create (ENV .API_URL )
3535
36- body_m4 := middlewares.BodyMiddleware {
37- Next : initHandler ,
36+ body_m5 := middlewares.BodyMiddleware {
37+ Next : proxy_last ,
3838 }
3939
40- temp_m3 := middlewares.TemplateMiddleware {
41- Next : body_m4 .Use (),
40+ temp_m4 := middlewares.TemplateMiddleware {
41+ Next : body_m5 .Use (),
4242 }
4343
44- endp_m2 := middlewares.EndpointsMiddleware {
45- Next : temp_m3 .Use (),
44+ endp_m3 := middlewares.EndpointsMiddleware {
45+ Next : temp_m4 .Use (),
4646 }
4747
48- auth_m1 := middlewares.AuthMiddleware {
49- Next : endp_m2 .Use (),
48+ auth_m2 := middlewares.AuthMiddleware {
49+ Next : endp_m3 .Use (),
50+ }
51+
52+ serv_m1 := middlewares.ServeMiddleware {
53+ Next : auth_m2 .Use (),
5054 }
5155
5256 log_m0 := middlewares.LogMiddleware {
53- Next : auth_m1 .Use (),
57+ Next : serv_m1 .Use (),
5458 }
5559
5660 log .Info ("Initialized Proxy Handler" )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import (
1717type ENV_ struct {
1818 CONFIG_PATH string
1919 DEFAULTS_PATH string
20+ FAVICON_PATH string
2021 TOKENS_DIR string
2122 LOG_LEVEL string
2223 PORT string
@@ -37,6 +38,7 @@ var ENV *ENV_ = &ENV_{
3738 CONFIG_PATH : os .Getenv ("CONFIG_PATH" ),
3839 DEFAULTS_PATH : os .Getenv ("DEFAULTS_PATH" ),
3940 TOKENS_DIR : os .Getenv ("TOKENS_DIR" ),
41+ FAVICON_PATH : os .Getenv ("FAVICON_PATH" ),
4042 API_TOKENS : []string {},
4143 SETTINGS : map [string ]* SETTING_ {
4244
You can’t perform that action at this time.
0 commit comments