ing
This commit is contained in:
parent
e059d8e0fd
commit
aa66a49925
|
@ -59,6 +59,7 @@ func (sh *ServerHandlers) Destroy(serverCtx server.ServerCtx) {
|
|||
}
|
||||
|
||||
func (sh *ServerHandlers) OnError(serverCtx server.ServerCtx, ctx *fasthttp.RequestCtx, status int, reason error) {
|
||||
ctx.Error(reason.Error(), status)
|
||||
}
|
||||
|
||||
func (sh *ServerHandlers) RegisterServlet(contextPath string, servlet Servlet) {
|
||||
|
|
|
@ -135,11 +135,10 @@ func (s *Server) handleServer(listener net.Listener) error {
|
|||
func (s *Server) httpHandler(ctx *fasthttp.RequestCtx) {
|
||||
var (
|
||||
servlet Servlet
|
||||
err error
|
||||
)
|
||||
|
||||
if servlet = s.ServerHandler.(ServerHandler).Servlet(s.ctx, ctx); nil == servlet {
|
||||
s.onError(ctx, fasthttp.StatusNotFound, err)
|
||||
if servlet = s.ServerHandler.Servlet(s.ctx, ctx); nil == servlet {
|
||||
s.onError(ctx, fasthttp.StatusNotFound, fmt.Errorf("Not Found"))
|
||||
return
|
||||
}
|
||||
servletCtx := servlet.ServletCtx(s.ctx)
|
||||
|
@ -148,5 +147,5 @@ func (s *Server) httpHandler(ctx *fasthttp.RequestCtx) {
|
|||
}
|
||||
|
||||
func (s *Server) onError(ctx *fasthttp.RequestCtx, status int, reason error) {
|
||||
s.ServerHandler.(ServerHandler).OnError(s.ctx, ctx, status, reason)
|
||||
s.ServerHandler.OnError(s.ctx, ctx, status, reason)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user