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.
37 lines
595 B
37 lines
595 B
2 years ago
|
package xserver
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"net/http"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
2 years ago
|
type Http struct {
|
||
2 years ago
|
server *http.Server
|
||
|
}
|
||
|
|
||
2 years ago
|
func (h *Http) Start() error {
|
||
2 years ago
|
return h.server.ListenAndServe()
|
||
|
}
|
||
|
|
||
2 years ago
|
func (h *Http) Shutdown(ctx context.Context) error {
|
||
2 years ago
|
return h.server.Shutdown(ctx)
|
||
|
}
|
||
|
|
||
2 years ago
|
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,
|
||
|
},
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
func (c *Http) Name() string {
|
||
2 years ago
|
return "http"
|
||
|
}
|