Remove Buffalo (#1010)

* Remove Buffalo

* gofmt

* pr fixes

* fix subrouter

* bring back secure middleware + pr fixes

* better place for subrouter

* vendor
This commit is contained in:
Marwan Sulaiman
2018-12-22 20:24:25 -05:00
committed by GitHub
parent 36aba5915c
commit 5870aeee8d
1129 changed files with 465 additions and 371408 deletions
+10 -9
View File
@@ -4,20 +4,21 @@ import (
"crypto/subtle"
"net/http"
"github.com/gobuffalo/buffalo"
"github.com/gorilla/mux"
)
func basicAuth(user, pass string) buffalo.MiddlewareFunc {
return func(next buffalo.Handler) buffalo.Handler {
return func(c buffalo.Context) error {
if !checkAuth(c.Request(), user, pass) {
c.Response().Header().Set("WWW-Authenticate", `Basic realm="basic auth required"`)
c.Render(http.StatusUnauthorized, nil)
return nil
func basicAuth(user, pass string) mux.MiddlewareFunc {
return func(h http.Handler) http.Handler {
f := func(w http.ResponseWriter, r *http.Request) {
if !checkAuth(r, user, pass) {
w.Header().Set("WWW-Authenticate", `Basic realm="basic auth required"`)
w.WriteHeader(http.StatusUnauthorized)
return
}
return next(c)
h.ServeHTTP(w, r)
}
return http.HandlerFunc(f)
}
}