server-go/web/fasthttp/servlet.go
crusader 6bf0de295a ing
2018-04-10 23:06:39 +09:00

51 lines
1023 B
Go

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