mirror of https://github.com/jlelse/GoBlog
Simple blogging system written in Go
https://goblog.app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
453 B
22 lines
453 B
package main |
|
|
|
import ( |
|
"net/http" |
|
|
|
"github.com/justinas/alice" |
|
) |
|
|
|
func (a *goBlog) isPrivate() bool { |
|
return a.cfg.PrivateMode != nil && a.cfg.PrivateMode.Enabled |
|
} |
|
|
|
func (a *goBlog) privateModeHandler(next http.Handler) http.Handler { |
|
private := alice.New(a.authMiddleware).Then(next) |
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
|
if a.isPrivate() { |
|
private.ServeHTTP(w, r) |
|
return |
|
} |
|
next.ServeHTTP(w, r) |
|
}) |
|
}
|
|
|