a8862721cd
Static directory for public folders and business logic for the app within internal, split into domain specific folders to keep clear seperation of concerns.
36 lines
497 B
Go
36 lines
497 B
Go
package web
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"nfeeder/internal/db"
|
|
)
|
|
|
|
type Server struct {
|
|
httpServer *http.Server
|
|
store *db.Store
|
|
}
|
|
|
|
func NewServer(store *db.Store) *Server {
|
|
s := &Server {
|
|
store: store,
|
|
}
|
|
|
|
s.httpServer = &http.Server {
|
|
Handler: s.setupRoutes(),
|
|
}
|
|
|
|
return s
|
|
}
|
|
|
|
func (s *Server) Start(addr string) error {
|
|
s.httpServer.Addr = addr
|
|
return s.httpServer.ListenAndServe()
|
|
}
|
|
|
|
func (s *Server) Shutdown(ctx context.Context) error {
|
|
return s.httpServer.Shutdown(ctx)
|
|
}
|
|
|