46 lines
998 B
Go
46 lines
998 B
Go
// Code generated by Wire. DO NOT EDIT.
|
|
|
|
//go:generate wire
|
|
//+build !wireinject
|
|
|
|
package web
|
|
|
|
import (
|
|
"github.com/go-chi/chi"
|
|
"github.com/ollien/updown/config"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
// Injectors from wire_stubs.go:
|
|
|
|
func initWebserver(serverConfig config.ServerConfig) *Webserver {
|
|
router := provideRouter()
|
|
server := provideHTTPServer(serverConfig, router)
|
|
webserver := provideWebserver(server, router)
|
|
return webserver
|
|
}
|
|
|
|
// wire_stubs.go:
|
|
|
|
func provideHTTPServer(serverConfig config.ServerConfig, router chi.Router) *http.Server {
|
|
return &http.Server{
|
|
Addr: serverConfig.ListenAddr + ":" + strconv.Itoa(serverConfig.Port),
|
|
Handler: router,
|
|
}
|
|
}
|
|
|
|
func provideWebserver(httpServer *http.Server, router chi.Router) *Webserver {
|
|
webserver := Webserver{
|
|
httpServer: httpServer,
|
|
router: router,
|
|
}
|
|
|
|
return &webserver
|
|
}
|
|
|
|
// provideRouter allows us to use the interface type for Chi's mux, rather than the struct
|
|
func provideRouter() chi.Router {
|
|
return chi.NewRouter()
|
|
}
|