package fasthttp import ( "strings" "git.loafle.net/commons/server-go" "git.loafle.net/commons/server-go/web" "github.com/valyala/fasthttp" ) type Servlet interface { web.Servlet Handle(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) *web.Error RequestPath(ctx *fasthttp.RequestCtx) string } type Servlets struct { Servlet ContextPath string } func (s *Servlets) ServletCtx(serverCtx server.ServerCtx) server.ServletCtx { return server.NewServletContext(nil, serverCtx) } func (s *Servlets) Init(serverCtx server.ServerCtx) error { return nil } func (s *Servlets) OnStart(serverCtx server.ServerCtx) error { return nil } func (s *Servlets) OnStop(serverCtx server.ServerCtx) { // } func (s *Servlets) Destroy(serverCtx server.ServerCtx) { // } func (s *Servlets) Handle(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) *web.Error { return nil } func (s *Servlets) RequestPath(ctx *fasthttp.RequestCtx) string { return strings.Replace(string(ctx.Path()), s.ContextPath, "", -1) }