mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Cleanup main (#470)
* main: clean up * server: replace magical constants and use them for app name tracking
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var ErrNoSpecialHandlerFound = errors.New("Path not found")
|
||||
|
||||
type SpecialHandler interface {
|
||||
Handle(c HandlerContext) error
|
||||
}
|
||||
@@ -53,6 +55,10 @@ func (s *Server) AddSpecialHandler(handler SpecialHandler) {
|
||||
|
||||
// UseSpecialHandlers execute all special handlers
|
||||
func (s *Server) UseSpecialHandlers(ctx context.Context, req *http.Request, resp http.ResponseWriter) (context.Context, error) {
|
||||
if len(s.specialHandlers) == 0 {
|
||||
return ctx, ErrNoSpecialHandlerFound
|
||||
}
|
||||
|
||||
c := &SpecialHandlerContext{
|
||||
request: req,
|
||||
response: resp,
|
||||
|
||||
Reference in New Issue
Block a user