@@ -16,18 +16,18 @@ type HttpServer struct {
16
16
upgrader websocket.Upgrader
17
17
}
18
18
19
- func NewHTTPServer (addr , username , password string , actionsEnabled bool , pm2 * PM2 ) * HttpServer {
19
+ func NewHTTPServer (addr string , options * Options , pm2 * PM2 ) * HttpServer {
20
20
return (& HttpServer {
21
21
upgrader : websocket.Upgrader {
22
22
ReadBufferSize : 1024 ,
23
23
WriteBufferSize : 1024 ,
24
24
CheckOrigin : func (r * http.Request ) bool { return true },
25
25
},
26
26
Addr : addr ,
27
- }).init (username , password , actionsEnabled , pm2 )
27
+ }).init (options , pm2 )
28
28
}
29
29
30
- func (s * HttpServer ) init (username , password string , actionsEnabled bool , pm2 * PM2 ) * HttpServer {
30
+ func (s * HttpServer ) init (options * Options , pm2 * PM2 ) * HttpServer {
31
31
staticHandler := http .FileServer (http .Dir ("./static" ))
32
32
33
33
jsHandler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -37,7 +37,7 @@ func (s *HttpServer) init(username, password string, actionsEnabled bool, pm2 *P
37
37
return
38
38
}
39
39
w .Header ().Add ("Content-Type" , "text/javascript" )
40
- err = templ .Execute (w , actionsEnabled )
40
+ err = templ .Execute (w , options )
41
41
if err != nil {
42
42
fmt .Println (err )
43
43
}
@@ -131,19 +131,19 @@ func (s *HttpServer) init(username, password string, actionsEnabled bool, pm2 *P
131
131
}
132
132
})
133
133
134
- if username == "" {
134
+ if options . Username == "" {
135
135
http .Handle ("/" , staticHandler )
136
136
http .Handle ("/script.js" , jsHandler )
137
137
http .Handle ("/logs" , logsHandler )
138
- if actionsEnabled {
138
+ if options . ActionsEnabled {
139
139
http .Handle ("/action" , actionHandler )
140
140
}
141
141
} else {
142
- http .Handle ("/" , httpauth .SimpleBasicAuth (username , password )(staticHandler ))
143
- http .Handle ("/script.js" , httpauth .SimpleBasicAuth (username , password )(jsHandler ))
144
- http .Handle ("/logs" , httpauth .SimpleBasicAuth (username , password )(logsHandler ))
145
- if actionsEnabled {
146
- http .Handle ("/action" , httpauth .SimpleBasicAuth (username , password )(actionHandler ))
142
+ http .Handle ("/" , httpauth .SimpleBasicAuth (options . Username , options . Password )(staticHandler ))
143
+ http .Handle ("/script.js" , httpauth .SimpleBasicAuth (options . Username , options . Password )(jsHandler ))
144
+ http .Handle ("/logs" , httpauth .SimpleBasicAuth (options . Username , options . Password )(logsHandler ))
145
+ if options . ActionsEnabled {
146
+ http .Handle ("/action" , httpauth .SimpleBasicAuth (options . Username , options . Password )(actionHandler ))
147
147
}
148
148
}
149
149
0 commit comments