updown/web/wire_stubs.go

40 lines
948 B
Go

//+build wireinject
package web
import (
"net/http"
"strconv"
"github.com/go-chi/chi"
"github.com/google/wire"
"github.com/ollien/updown/config"
)
// initWebserver is generated by wire. Please see wire_gen.go for the generated implementation
func initWebserver(serverConfig config.ServerConfig) *Webserver {
wire.Build(provideWebserver, provideHTTPServer, provideRouter)
return &Webserver{}
}
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()
}