parent
653d0926f7
commit
5bfb5316f8
|
@ -164,7 +164,7 @@ func Handler(
|
||||||
|
|
||||||
// path:/ matches everything that isn't registerd (ie. its the "Not Found handler")
|
// path:/ matches everything that isn't registerd (ie. its the "Not Found handler")
|
||||||
mux.HandleFunc("/", http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
mux.HandleFunc("/", http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
r.Error(rw, req, 404, weberrors.ErrNotFound{What: req.URL.Path})
|
r.Error(rw, req, 404, weberrors.PageNotFound{Path: req.URL.Path})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return customStripPrefix("/admin", mux)
|
return customStripPrefix("/admin", mux)
|
||||||
|
|
|
@ -31,19 +31,6 @@ func TestIndex(t *testing.T) {
|
||||||
a.Equal("Default Notice Content", content)
|
a.Equal("Default Notice Content", content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAbout(t *testing.T) {
|
|
||||||
ts := setup(t)
|
|
||||||
|
|
||||||
a := assert.New(t)
|
|
||||||
|
|
||||||
url := ts.URLTo(router.CompleteAbout)
|
|
||||||
|
|
||||||
html, resp := ts.Client.GetHTML(url)
|
|
||||||
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
|
||||||
found := html.Find("h1").Text()
|
|
||||||
a.Equal("The about page", found)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNotFound(t *testing.T) {
|
func TestNotFound(t *testing.T) {
|
||||||
ts := setup(t)
|
ts := setup(t)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import (
|
||||||
|
|
||||||
var HTMLTemplates = []string{
|
var HTMLTemplates = []string{
|
||||||
"landing/index.tmpl",
|
"landing/index.tmpl",
|
||||||
"landing/about.tmpl",
|
|
||||||
"alias.tmpl",
|
"alias.tmpl",
|
||||||
|
|
||||||
"change-member-password.tmpl",
|
"change-member-password.tmpl",
|
||||||
|
@ -407,7 +406,6 @@ func New(
|
||||||
Language: notice.Language,
|
Language: notice.Language,
|
||||||
}, nil
|
}, nil
|
||||||
}))
|
}))
|
||||||
m.Get(router.CompleteAbout).Handler(r.StaticHTML("landing/about.tmpl"))
|
|
||||||
|
|
||||||
// notices (the mini-CMS)
|
// notices (the mini-CMS)
|
||||||
var nh = noticeHandler{
|
var nh = noticeHandler{
|
||||||
|
@ -446,22 +444,22 @@ func New(
|
||||||
m.Get(router.CompleteInviteInsertID).Handler(r.HTML("invite/insert-id.tmpl", ih.presentInsert))
|
m.Get(router.CompleteInviteInsertID).Handler(r.HTML("invite/insert-id.tmpl", ih.presentInsert))
|
||||||
m.Get(router.CompleteInviteConsume).HandlerFunc(ih.consume)
|
m.Get(router.CompleteInviteConsume).HandlerFunc(ih.consume)
|
||||||
|
|
||||||
// statuc assets
|
// static assets
|
||||||
m.PathPrefix("/assets/").Handler(http.StripPrefix("/assets/", http.FileServer(web.Assets)))
|
m.PathPrefix("/assets/").Handler(http.StripPrefix("/assets/", http.FileServer(web.Assets)))
|
||||||
|
|
||||||
|
// TODO: doesnt work because of of mainMux wrapper, see issue #35
|
||||||
m.NotFoundHandler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
m.NotFoundHandler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
eh.Handle(rw, req, http.StatusNotFound, weberrs.PageNotFound{Path: req.URL.Path})
|
eh.Handle(rw, req, http.StatusNotFound, weberrs.PageNotFound{Path: req.URL.Path})
|
||||||
})
|
})
|
||||||
|
|
||||||
// hook up main stdlib mux to the gorrilla/mux with named routes
|
// hook up main stdlib mux to the gorrilla/mux with named routes
|
||||||
|
// TODO: issue #35
|
||||||
mainMux.Handle("/", m)
|
mainMux.Handle("/", m)
|
||||||
|
|
||||||
consumeURL := urlTo(router.CompleteInviteConsume)
|
consumeURL := urlTo(router.CompleteInviteConsume)
|
||||||
|
|
||||||
// apply HTTP middleware
|
// apply HTTP middleware
|
||||||
middlewares := []func(http.Handler) http.Handler{
|
middlewares := []func(http.Handler) http.Handler{
|
||||||
logging.RecoveryHandler(),
|
|
||||||
logging.InjectHandler(logger),
|
|
||||||
members.ContextInjecter(dbs.Members, authWithPassword, authWithSSB),
|
members.ContextInjecter(dbs.Members, authWithPassword, authWithSSB),
|
||||||
CSRF,
|
CSRF,
|
||||||
|
|
||||||
|
@ -477,6 +475,9 @@ func New(
|
||||||
next.ServeHTTP(w, req)
|
next.ServeHTTP(w, req)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
logging.InjectHandler(logger),
|
||||||
|
logging.RecoveryHandler(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if !web.Production {
|
if !web.Production {
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
{{ define "title" }}Landing - About{{ end }}
|
|
||||||
{{ define "content" }}
|
|
||||||
<div>
|
|
||||||
<h1>The about page</h1>
|
|
||||||
</div>
|
|
||||||
</div> <!-- /row -->
|
|
||||||
{{end}}
|
|
Loading…
Reference in New Issue