28 lines
433 B
Go
28 lines
433 B
Go
package httpserver
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
type HTTPServer struct {
|
|
server *http.Server
|
|
}
|
|
|
|
func NewHTTPServer(addr string, handler http.Handler) *HTTPServer {
|
|
return &HTTPServer{
|
|
server: &http.Server{
|
|
Addr: addr,
|
|
Handler: handler,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (s *HTTPServer) Start() error {
|
|
return s.server.ListenAndServe()
|
|
}
|
|
|
|
func (s *HTTPServer) Shutdown(ctx context.Context) error {
|
|
return s.server.Shutdown(ctx)
|
|
}
|