nuke everything, start over
This commit is contained in:
parent
e261de7060
commit
a2a937791d
44 changed files with 7 additions and 1106 deletions
|
@ -1,37 +0,0 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"gitlab.com/mstarongitlab/linstrom/config"
|
||||
"gitlab.com/mstarongitlab/linstrom/guardian"
|
||||
"gitlab.com/mstarongitlab/linstrom/storage"
|
||||
"gitlab.com/mstarongitlab/weblogger"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
// Register routes on here
|
||||
Router *httprouter.Router
|
||||
// Where to read and write stuff from
|
||||
Storage *storage.Storage
|
||||
// Global config. READ ONLY
|
||||
Config *config.Config
|
||||
// Final handler given to http.ListenAndServe
|
||||
// Can be any router or middleware wrapped around a router
|
||||
handler http.Handler
|
||||
}
|
||||
|
||||
func NewServer(cfg *config.Config, s *storage.Storage) *Server {
|
||||
router := httprouter.New()
|
||||
return &Server{
|
||||
Router: router,
|
||||
Storage: s,
|
||||
Config: cfg,
|
||||
handler: guardian.NewMiddleware(weblogger.LoggingMiddleware(router), cfg, s),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Run() {
|
||||
http.ListenAndServe(":8080", s.handler)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue