clean up server files

This commit is contained in:
sentriz
2019-06-28 11:58:49 +01:00
parent 111ca565c8
commit a4377fc425
4 changed files with 21 additions and 23 deletions

View File

@@ -1,9 +0,0 @@
package server
import "errors"
var ErrAssetNotFound = errors.New("asset not found")
type Assets struct {
BasePath string
}

View File

@@ -1,6 +1,7 @@
package server
import (
"errors"
"net/http"
"time"
@@ -9,20 +10,6 @@ import (
"github.com/sentriz/gonic/server/handler"
)
type middleware func(next http.HandlerFunc) http.HandlerFunc
func newChain(wares ...middleware) middleware {
return func(final http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
last := final
for i := len(wares) - 1; i >= 0; i-- {
last = wares[i](last)
}
last(w, r)
}
}
}
type Server struct {
mux *http.ServeMux
assets *Assets
@@ -58,3 +45,23 @@ func New(
Controller: controller,
}
}
var ErrAssetNotFound = errors.New("asset not found")
type Assets struct {
BasePath string
}
type middleware func(next http.HandlerFunc) http.HandlerFunc
func newChain(wares ...middleware) middleware {
return func(final http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
last := final
for i := len(wares) - 1; i >= 0; i-- {
last = wares[i](last)
}
last(w, r)
}
}
}