updown/web/wire_gen.go

76 lines
2.0 KiB
Go

// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package web
import (
"github.com/go-chi/chi"
"github.com/gobuffalo/packr/v2"
"github.com/ollien/updown/config"
"github.com/ollien/updown/handler/log"
"github.com/ollien/updown/handler/paste"
"github.com/sirupsen/logrus"
"io"
log2 "log"
"net/http"
"strconv"
)
// Injectors from wire_stubs.go:
func initWebserver() *Webserver {
configConfig := config.Get()
router := provideRouter()
logger := log.Get()
pipeWriter := provideLogWriter(logger)
server := provideHTTPServer(configConfig, router, pipeWriter)
service := paste.NewService()
fileSystem := provideStaticFileHandler()
box := provideTemplateBox()
webserver := provideWebserver(server, router, service, logger, pipeWriter, fileSystem, box)
return webserver
}
// wire_stubs.go:
func provideHTTPServer(appConfig config.Config, router chi.Router, logWriter *io.PipeWriter) *http.Server {
return &http.Server{
Addr: appConfig.Server.ListenAddr + ":" + strconv.Itoa(appConfig.Server.Port),
Handler: router,
ErrorLog: log2.New(logWriter, "", 0),
}
}
func provideWebserver(httpServer *http.Server, router chi.Router, pasteService *paste.Service, logger *logrus.Logger, logWriter *io.PipeWriter, staticFileHandler http.FileSystem, templateBox *packr.Box) *Webserver {
webserver := Webserver{
httpServer: httpServer,
router: router,
logger: logger,
logWriter: logWriter,
pasteService: pasteService,
staticFiles: staticFileHandler,
templates: templateBox,
}
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()
}
func provideLogWriter(logger *logrus.Logger) *io.PipeWriter {
return logger.Writer()
}
func provideStaticFileHandler() http.FileSystem {
return packr.New("./static/", "static")
}
func provideTemplateBox() *packr.Box {
return packr.New("./templates/", "templates")
}