wip: add api auth and /resume endpoint

This commit is contained in:
cătălin 2023-12-04 22:13:37 +01:00
commit aaec8ec08d
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
23 changed files with 1244 additions and 271 deletions

32
internal/server/server.go Normal file
View file

@ -0,0 +1,32 @@
package server
import (
"context"
"net/http"
"git.roboces.dev/catalin/cvvvvv/internal/config"
)
type Server struct {
httpServer *http.Server
}
func NewServer(cfg *config.Config, handler http.Handler) *Server {
return &Server{
httpServer: &http.Server{
Addr: ":" + cfg.HTTP.Port,
Handler: handler,
ReadTimeout: cfg.HTTP.ReadTimeout,
WriteTimeout: cfg.HTTP.WriteTimeout,
MaxHeaderBytes: cfg.HTTP.MaxHeaderMegabytes << 20,
},
}
}
func (s *Server) Run() error {
return s.httpServer.ListenAndServe()
}
func (s *Server) Stop(ctx context.Context) error {
return s.httpServer.Shutdown(ctx)
}