mirror of https://github.com/tilde-cat/register
Added lost error page
This commit is contained in:
parent
9360aeea76
commit
6d98ec50f5
5
main.go
5
main.go
|
@ -125,11 +125,16 @@ func (s *Server) FormPage(w http.ResponseWriter, r *http.Request) {
|
|||
formTemplate.Execute(w, config)
|
||||
}
|
||||
|
||||
func (s *Server) ErrorPage(w http.ResponseWriter, r *http.Request) {
|
||||
errorTemplate.Execute(w, config)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var io FsIo
|
||||
server := Server{Io: &io}
|
||||
http.HandleFunc(RequestStatusUrlPrefix, server.RequestPage)
|
||||
http.HandleFunc(FormPostUrl, server.FormPostHandler)
|
||||
http.HandleFunc(FormUrl, server.FormPage)
|
||||
http.HandleFunc(ErrorUrl, server.ErrorPage)
|
||||
log.Fatal(http.ListenAndServe("localhost:5678", nil))
|
||||
}
|
||||
|
|
|
@ -18,6 +18,12 @@ var statusTemplate = template.Must(footer.New("status").Parse(`
|
|||
Status: {{ .Status }}
|
||||
{{ template "footer" .Global }}`))
|
||||
|
||||
var errorTemplate = template.Must(footer.New("error").Parse(`
|
||||
{{ template "header" . }}
|
||||
<p>Error, all form fields must be field.</p>
|
||||
<a href="/">take ma back</a>
|
||||
{{ template "footer" . }}`))
|
||||
|
||||
var formTemplate = template.Must(header.New("form").Parse(`{{ template "header" . }}
|
||||
<h1>~🐱 Sign up form</h1>
|
||||
<form action="/post" method="post">
|
||||
|
|
Loading…
Reference in New Issue