1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00
strimertul/webserver/http.go

30 lines
476 B
Go
Raw Normal View History

package webserver
import (
"context"
"net/http"
)
type ServerFactory = func(h http.Handler, addr string) (Server, error)
func DefaultServerFactory(h http.Handler, addr string) (Server, error) {
return &HTTPServer{http.Server{
Addr: addr,
Handler: h,
}}, nil
}
type Server interface {
Start() error
Close() error
Shutdown(ctx context.Context) error
}
type HTTPServer struct {
http.Server
}
func (s *HTTPServer) Start() error {
return s.ListenAndServe()
}