clean up server files
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package server
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrAssetNotFound = errors.New("asset not found")
|
||||
|
||||
type Assets struct {
|
||||
BasePath string
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user