Add text templates to endpoints
This commit is contained in:
parent
b57652e6d2
commit
55e6be7239
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"lishwist/http/session"
|
"lishwist/http/session"
|
||||||
"lishwist/http/templates"
|
"lishwist/http/templates"
|
||||||
|
"lishwist/http/templates/text"
|
||||||
|
|
||||||
"github.com/Teajey/rsvp"
|
"github.com/Teajey/rsvp"
|
||||||
)
|
)
|
||||||
|
|
@ -18,6 +19,7 @@ type ServeMux struct {
|
||||||
func NewServeMux(store *session.Store) *ServeMux {
|
func NewServeMux(store *session.Store) *ServeMux {
|
||||||
mux := rsvp.NewServeMux()
|
mux := rsvp.NewServeMux()
|
||||||
mux.Config.HtmlTemplate = templates.Template
|
mux.Config.HtmlTemplate = templates.Template
|
||||||
|
mux.Config.TextTemplate = text.Template
|
||||||
return &ServeMux{
|
return &ServeMux{
|
||||||
inner: mux,
|
inner: mux,
|
||||||
store: store,
|
store: store,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
Just a normal login form. Takes the following form values:
|
||||||
|
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
|
||||||
|
Upon successful login, a redirect to the same URL on the protected router is issued.
|
||||||
|
|
||||||
|
A registration page is also available at /register
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
Register with the following form values:
|
||||||
|
|
||||||
|
username string
|
||||||
|
newPassword string
|
||||||
|
confirmPassword string
|
||||||
|
|
||||||
|
All must be provided, username must be unique, newPassword and confirmPassword must be identical.
|
||||||
|
|
||||||
|
It's worth considering that having two password form parameters isn't very helpful on the command line, it's only really useful to the browser.
|
||||||
|
Therefore, it might be a good idea to have Javascript check these two fields are identical, and submit, rather than having this
|
||||||
|
checked by the server. Meaning only one password field needs to be submitted to the server. That does block non-Javascript browsers tho :^P
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package text
|
||||||
|
|
||||||
|
import (
|
||||||
|
"text/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Template *template.Template
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Template = load()
|
||||||
|
}
|
||||||
|
|
||||||
|
func load() *template.Template {
|
||||||
|
t := template.Must(template.ParseGlob("templates/text/*.gotmpl"))
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue