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
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -9,20 +10,6 @@ import (
|
|||||||
"github.com/sentriz/gonic/server/handler"
|
"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 {
|
type Server struct {
|
||||||
mux *http.ServeMux
|
mux *http.ServeMux
|
||||||
assets *Assets
|
assets *Assets
|
||||||
@@ -58,3 +45,23 @@ func New(
|
|||||||
Controller: controller,
|
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