go fmt
This commit is contained in:
parent
f819320f5a
commit
b8d9118b56
4 changed files with 11 additions and 16 deletions
11
main.go
11
main.go
|
|
@ -18,14 +18,13 @@ import (
|
|||
)
|
||||
|
||||
var myLDAP = LDAP{
|
||||
Host: "localhost",
|
||||
Port: 389,
|
||||
Host: "localhost",
|
||||
Port: 389,
|
||||
BaseDN: "dc=example,dc=com",
|
||||
}
|
||||
|
||||
|
||||
type ResponseWriterPrefix struct {
|
||||
real http.ResponseWriter
|
||||
real http.ResponseWriter
|
||||
prefix string
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ func (r ResponseWriterPrefix) Header() http.Header {
|
|||
|
||||
func (r ResponseWriterPrefix) WriteHeader(s int) {
|
||||
if v, exists := r.real.Header()["Location"]; exists {
|
||||
r.real.Header().Set("Location", r.prefix + v[0])
|
||||
r.real.Header().Set("Location", r.prefix+v[0])
|
||||
}
|
||||
r.real.WriteHeader(s)
|
||||
}
|
||||
|
|
@ -50,7 +49,7 @@ func StripPrefix(prefix string, h http.Handler) http.Handler {
|
|||
}
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if prefix != "/" && r.URL.Path == "/" {
|
||||
http.Redirect(w, r, prefix + "/", http.StatusFound)
|
||||
http.Redirect(w, r, prefix+"/", http.StatusFound)
|
||||
} else if p := strings.TrimPrefix(r.URL.Path, prefix); len(p) < len(r.URL.Path) {
|
||||
r2 := new(http.Request)
|
||||
*r2 = *r
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue