Files
push-server/interval/server/httpserver/http.go
R2m1liA 53555a31c0 refactor: 重构项目结构
- 将server端相关依赖单独防止在server中
2025-12-17 12:34:03 +08:00

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