Merge branch 'master' of github.com:jchenry/x
This commit is contained in:
commit
7facc0732f
6
go.mod
6
go.mod
@ -1,9 +1,3 @@
|
|||||||
module github.com/jchenry/x
|
module github.com/jchenry/x
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/julienschmidt/httprouter v1.2.0
|
|
||||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
|
|
||||||
rsc.io/dbstore v0.1.1
|
|
||||||
)
|
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BasicAuth(fn http.HandlerFunc) http.HandlerFunc {
|
func BasicAuth(h http.Handler) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
user, pass, _ := r.BasicAuth()
|
user, pass, _ := r.BasicAuth()
|
||||||
if !(user == os.Getenv("WIKI_USERNAME") && pass == os.Getenv("WIKI_PASSWORD")) {
|
if !(user == os.Getenv("WIKI_USERNAME") && pass == os.Getenv("WIKI_PASSWORD")) {
|
||||||
@ -13,6 +13,7 @@ func BasicAuth(fn http.HandlerFunc) http.HandlerFunc {
|
|||||||
http.Error(w, "Unauthorized.", 401)
|
http.Error(w, "Unauthorized.", 401)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fn(w, r)
|
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user