You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
595 B

package xserver
import (
"context"
"github.com/gin-gonic/gin"
"net/http"
"time"
)
type Http struct {
server *http.Server
}
func (h *Http) Start() error {
return h.server.ListenAndServe()
}
func (h *Http) Shutdown(ctx context.Context) error {
return h.server.Shutdown(ctx)
}
func NewHttp(httpHost string, app *gin.Engine) *Http {
return &Http{
server: &http.Server{
Addr: httpHost,
Handler: app,
ReadTimeout: 60 * time.Second,
WriteTimeout: 60 * time.Second,
MaxHeaderBytes: 20 << 20,
},
}
}
func (c *Http) Name() string {
return "http"
}