test dynfunc package; standardize and refactor api #14
|
@ -73,7 +73,6 @@ func errorHandler(err api.Error) http.HandlerFunc {
|
||||||
return func(res http.ResponseWriter, req *http.Request) {
|
return func(res http.ResponseWriter, req *http.Request) {
|
||||||
r := api.EmptyResponse().WithError(err)
|
r := api.EmptyResponse().WithError(err)
|
||||||
r.ServeHTTP(res, req)
|
r.ServeHTTP(res, req)
|
||||||
logError(r)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
util.go
15
util.go
|
@ -1,15 +0,0 @@
|
||||||
package aicra
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"git.xdrm.io/go/aicra/api"
|
|
||||||
)
|
|
||||||
|
|
||||||
var handledMethods = []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete}
|
|
||||||
|
|
||||||
// Prints an error as HTTP response
|
|
||||||
func logError(res *api.Response) {
|
|
||||||
log.Printf("[http.fail] %v\n", res)
|
|
||||||
}
|
|
Loading…
Reference in New Issue