mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
move router to module New func
This commit is contained in:
@@ -23,7 +23,7 @@ type ResponseData struct {
|
||||
func init() {
|
||||
RegisterModule(ModuleRegistration{
|
||||
Type: "net.http.server",
|
||||
New: func(config config.ModuleConfig) (Module, error) {
|
||||
New: func(config config.ModuleConfig, router *Router) (Module, error) {
|
||||
params := config.Params
|
||||
port, ok := params["port"]
|
||||
if !ok {
|
||||
@@ -36,7 +36,7 @@ func init() {
|
||||
return nil, fmt.Errorf("net.http.server port must be uint16")
|
||||
}
|
||||
|
||||
return &HTTPServer{Port: uint16(portNum), config: config}, nil
|
||||
return &HTTPServer{Port: uint16(portNum), config: config, router: router}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -49,10 +49,6 @@ func (hs *HTTPServer) Type() string {
|
||||
return hs.config.Type
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) RegisterRouter(router *Router) {
|
||||
hs.router = router
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) HandleDefault(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user