master
parent
b1986e6bfc
commit
029cde0c91
1 changed files with 35 additions and 0 deletions
@ -0,0 +1,35 @@ |
||||
package xserver |
||||
|
||||
import ( |
||||
"context" |
||||
"github.com/gin-gonic/gin" |
||||
"net/http" |
||||
"time" |
||||
) |
||||
|
||||
type httpServer struct { |
||||
server *http.Server |
||||
} |
||||
|
||||
func (h *httpServer) Start() error { |
||||
return h.server.ListenAndServe() |
||||
} |
||||
|
||||
func (h *httpServer) Shutdown(ctx context.Context) error { |
||||
return h.server.Shutdown(ctx) |
||||
} |
||||
|
||||
func NewHttp(httpHost string, app *gin.Engine) *httpServer { |
||||
server := &http.Server{ |
||||
Addr: httpHost, |
||||
Handler: app, |
||||
ReadTimeout: 60 * time.Second, |
||||
WriteTimeout: 60 * time.Second, |
||||
MaxHeaderBytes: 20 << 20, |
||||
} |
||||
return &httpServer{server: server} |
||||
} |
||||
|
||||
func (c *httpServer) Name() string { |
||||
return "http" |
||||
} |
Loading…
Reference in new issue