feature: add http middleware capability #18

Merged
xdrm-brackets merged 5 commits from feature/middleware into 0.3.0 2021-04-18 16:08:12 +00:00
1 changed files with 0 additions and 10 deletions
Showing only changes of commit 3986f7a022 - Show all commits

View File

@ -1,7 +1,6 @@
package aicra package aicra
import ( import (
"log"
"net/http" "net/http"
"git.xdrm.io/go/aicra/api" "git.xdrm.io/go/aicra/api"
@ -23,15 +22,6 @@ func (s Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
func (s Handler) handleRequest(w http.ResponseWriter, r *http.Request) { func (s Handler) handleRequest(w http.ResponseWriter, r *http.Request) {
defer func() {
if rc := recover(); rc != nil {
log.Printf("recovering request: %s\n", rc)
// try to send error response
api.EmptyResponse().WithError(api.ErrUncallableService).ServeHTTP(w, r)
}
}()
defer r.Body.Close()
// 1. find a matching service from config // 1. find a matching service from config
var service = s.conf.Find(r) var service = s.conf.Find(r)
if service == nil { if service == nil {