Files
push-server/interval/server/http.go
R2m1liA 9bac821750 feat: 基本HTTP服务器
- REST API: health用于检测服务器REST API正常运行
2025-12-16 15:07:52 +08:00

28 lines
429 B
Go

package server
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)
}