Cleanup main (#470)

* main: clean up

* server: replace magical constants and use them for app name tracking
This commit is contained in:
Travis Reeder
2017-01-03 14:59:26 -08:00
committed by GitHub
parent e75e115180
commit 1c8d12b09e
18 changed files with 203 additions and 129 deletions

View File

@@ -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,