mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 21:19:19 +00:00
rename skipauth -> manualauth
This commit is contained in:
parent
0e2da62081
commit
05634ebdb7
@ -22,8 +22,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var routes []Route = []Route{
|
var routes []Route = []Route{
|
||||||
p("/", IndexHandler).SkipAuth(),
|
p("/", IndexHandler).ManualAuth(),
|
||||||
p("/static/*path", StaticHandler).SkipAuth(),
|
p("/static/*path", StaticHandler).ManualAuth(),
|
||||||
|
p("/fever/", FeverHandler).ManualAuth(),
|
||||||
|
|
||||||
p("/api/status", StatusHandler),
|
p("/api/status", StatusHandler),
|
||||||
p("/api/folders", FolderListHandler),
|
p("/api/folders", FolderListHandler),
|
||||||
p("/api/folders/:id", FolderHandler),
|
p("/api/folders/:id", FolderHandler),
|
||||||
@ -38,7 +40,6 @@ var routes []Route = []Route{
|
|||||||
p("/opml/import", OPMLImportHandler),
|
p("/opml/import", OPMLImportHandler),
|
||||||
p("/opml/export", OPMLExportHandler),
|
p("/opml/export", OPMLExportHandler),
|
||||||
p("/page", PageCrawlHandler),
|
p("/page", PageCrawlHandler),
|
||||||
p("/fever/", FeverHandler).SkipAuth(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type asset struct {
|
type asset struct {
|
||||||
|
@ -9,11 +9,11 @@ type Route struct {
|
|||||||
url string
|
url string
|
||||||
urlRegex *regexp.Regexp
|
urlRegex *regexp.Regexp
|
||||||
handler func(http.ResponseWriter, *http.Request)
|
handler func(http.ResponseWriter, *http.Request)
|
||||||
skipAuth bool
|
manualAuth bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Route) SkipAuth() Route {
|
func (r Route) ManualAuth() Route {
|
||||||
r.skipAuth = true
|
r.manualAuth = true
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.requiresAuth() && !route.skipAuth {
|
if h.requiresAuth() && !route.manualAuth {
|
||||||
if !userIsAuthenticated(req, h.Username, h.Password) {
|
if !userIsAuthenticated(req, h.Username, h.Password) {
|
||||||
rw.WriteHeader(http.StatusUnauthorized)
|
rw.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user