diff --git a/core/internal/assert/assert.go b/assert/assert.go similarity index 100% rename from core/internal/assert/assert.go rename to assert/assert.go diff --git a/assert/go.mod b/assert/go.mod new file mode 100644 index 0000000..975d80c --- /dev/null +++ b/assert/go.mod @@ -0,0 +1,5 @@ +module lishwist/assert + +go 1.23.0 + +toolchain go1.23.3 diff --git a/core/internal/assert/snapshot.go b/assert/snapshot.go similarity index 66% rename from core/internal/assert/snapshot.go rename to assert/snapshot.go index f219d8e..2f7442b 100644 --- a/core/internal/assert/snapshot.go +++ b/assert/snapshot.go @@ -2,9 +2,10 @@ package assert import ( "encoding/json" + "encoding/xml" "errors" - "fmt" "os" + "strings" "testing" ) @@ -13,6 +14,13 @@ func pathExists(path string) bool { return !errors.Is(err, os.ErrNotExist) } +func ensureSuffix(s, suffix string) string { + if !strings.HasSuffix(s, suffix) { + s = s + suffix + } + return s +} + func writeSnapshot(t *testing.T, path, actual string) { f, err := os.Create(path) if err != nil { @@ -35,14 +43,18 @@ func TextSnapshot(t *testing.T, path, actual string) { return } + actual = ensureSuffix(actual, "\n") + content, err := os.ReadFile(path) if err != nil { t.Fatalf("Failed to read snapshot file: %s", err) } expected := string(content) + expected = ensureSuffix(expected, "\n") + if expected != actual { - t.Errorf("Value doesn't match snapshot %s:\n%s", path, actual) + t.Errorf("Value doesn't match snapshot %s:\n\nExpected:\n%s\n\nActual:\n%s\n", path, expected, actual) } if os.Getenv("UPDATE_SNAPSHOTS") == "" { @@ -50,7 +62,7 @@ func TextSnapshot(t *testing.T, path, actual string) { } writeSnapshot(t, path, actual) - fmt.Printf("Snapshot file %s updated\n", path) + t.Logf("Snapshot file %s updated\n", path) } func JsonSnapshot(t *testing.T, path string, actual any) { @@ -60,3 +72,11 @@ func JsonSnapshot(t *testing.T, path string, actual any) { } TextSnapshot(t, path, string(data)) } + +func XmlSnapshot(t *testing.T, path string, actual any) { + data, err := xml.MarshalIndent(actual, "", " ") + if err != nil { + t.Fatalf("Snapshot failed to serialize actual to XML: %s", err) + } + TextSnapshot(t, path, string(data)) +} diff --git a/core/wish_test.go b/core/wish_test.go index a0905de..00872c8 100644 --- a/core/wish_test.go +++ b/core/wish_test.go @@ -3,7 +3,7 @@ package lishwist_test import ( "testing" - "lishwist/core/internal/assert" + "lishwist/assert" "lishwist/core/internal/fixtures" ) diff --git a/go.work b/go.work index 7afb314..5118191 100644 --- a/go.work +++ b/go.work @@ -1,6 +1,7 @@ go 1.24.5 use ( + ./assert ./core ./http ) diff --git a/http/api/login.go b/http/api/login.go deleted file mode 100644 index 21dbf93..0000000 --- a/http/api/login.go +++ /dev/null @@ -1,43 +0,0 @@ -package api - -import ( - "lishwist/http/templates" -) - -type LoginProps struct { - GeneralError string `json:",omitempty"` - SuccessfulRegistration bool `json:",omitempty"` - SuccessfulSetPassword bool `json:",omitempty"` - Username templates.InputProps - Password templates.InputProps -} - -func NewLoginProps(username, password string) *LoginProps { - return &LoginProps{ - Username: templates.InputProps{ - Name: "username", - Required: true, - Value: username, - }, - Password: templates.InputProps{ - Name: "password", - Type: "password", - Required: true, - Value: password, - }, - } -} - -func (p *LoginProps) Validate() (valid bool) { - valid = true - - if !p.Username.Validate() { - valid = false - } - - if !p.Password.Validate() { - valid = false - } - - return -} diff --git a/http/api/register.go b/http/api/register.go deleted file mode 100644 index debaa52..0000000 --- a/http/api/register.go +++ /dev/null @@ -1,97 +0,0 @@ -package api - -import ( - "lishwist/http/templates" -) - -type RegisterProps struct { - Navbar templates.NavCollapse - GeneralError string `json:",omitempty"` - Username templates.InputProps - Password templates.InputProps - ConfirmPassword templates.InputProps -} - -func (p *RegisterProps) Validate() (valid bool) { - valid = true - - if p.Password.Value != p.ConfirmPassword.Value { - p.ConfirmPassword.Error = "Passwords didn't match" - valid = false - } - - if !p.Username.Validate() { - valid = false - } - - if !p.Password.Validate() { - valid = false - } - - if !p.ConfirmPassword.Validate() { - valid = false - } - - return -} - -func NewRegisterProps(usernameVal, passwordVal, confirmPassVal string) *RegisterProps { - return &RegisterProps{ - Navbar: templates.DefaultNavCollapse(), - GeneralError: "", - Username: templates.InputProps{ - Name: "username", - Required: true, - MinLength: 4, - Value: usernameVal, - }, - Password: templates.InputProps{ - Type: "password", - Name: "newPassword", - Required: true, - MinLength: 5, - Value: passwordVal, - }, - ConfirmPassword: templates.InputProps{ - Type: "password", - Name: "confirmPassword", - Required: true, - Value: confirmPassVal, - }, - } -} - -// func Register(username, newPassword, confirmPassword string) *RegisterProps { -// props := NewRegisterProps(username, newPassword, confirmPassword) - -// valid := props.Validate() -// props.Password.Value = "" -// props.ConfirmPassword.Value = "" -// if !valid { -// log.Printf("Invalid props: %#v\n", props) -// return props -// } - -// existingUser, _ := db.GetUserByName(username) -// if existingUser != nil { -// log.Printf("Username is taken: %q\n", existingUser.NormalName) -// props.Username.Error = "Username is taken" -// return props -// } - -// hashedPasswordBytes, err := bcrypt.GenerateFromPassword([]byte(newPassword), bcrypt.MinCost) -// if err != nil { -// log.Printf("Failed to hash password: %s\n", err) -// props.GeneralError = "Something went wrong. Error code: Aang" -// return props -// } - -// _, err = db.CreateUser(username, hashedPasswordBytes) -// if err != nil { -// log.Printf("Failed to create user: %s\n", err) -// props.GeneralError = "Something went wrong. Error code: Ozai" -// return props -// } - -// return nil -// } diff --git a/http/props/htmlx/TestFormXmlRender.snap.xml b/http/props/htmlx/TestFormXmlRender.snap.xml new file mode 100644 index 0000000..62d57d9 --- /dev/null +++ b/http/props/htmlx/TestFormXmlRender.snap.xml @@ -0,0 +1,3 @@ +
diff --git a/http/props/htmlx/form.go b/http/props/htmlx/form.go new file mode 100644 index 0000000..fce84d6 --- /dev/null +++ b/http/props/htmlx/form.go @@ -0,0 +1,28 @@ +package htmlx + +import ( + "encoding/xml" +) + +type Form struct { + Method string + Content any `json:"Form"` +} + +func (i Form) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + start.Name = xml.Name{Local: "Form"} + + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Method"}, Value: i.Method}) + + err := e.EncodeToken(start) + if err != nil { + return err + } + + err = e.Encode(i.Content) + if err != nil { + return err + } + + return e.EncodeToken(start.End()) +} diff --git a/http/props/htmlx/form_test.go b/http/props/htmlx/form_test.go new file mode 100644 index 0000000..0ad91cb --- /dev/null +++ b/http/props/htmlx/form_test.go @@ -0,0 +1,17 @@ +package htmlx_test + +import ( + "testing" + + "lishwist/assert" + "lishwist/http/props/htmlx" +) + +func TestFormXmlRender(t *testing.T) { + form := htmlx.Form{ + Method: "POST", + Content: htmlx.Input{Label: "Message", Name: "message"}, + } + + assert.XmlSnapshot(t, "TestFormXmlRender.snap.xml", form) +} diff --git a/http/props/htmlx/input.go b/http/props/htmlx/input.go new file mode 100644 index 0000000..020862e --- /dev/null +++ b/http/props/htmlx/input.go @@ -0,0 +1,66 @@ +package htmlx + +import ( + "encoding/xml" + "fmt" +) + +type Input struct { + // TODO: Perhaps inputs should be allowed to have children. + Label string + Type string `json:",omitempty"` + Name string + Required bool `json:",omitempty"` + Value string + MinLength uint `json:",omitempty"` + Error string `json:",omitempty"` +} + +func (i Input) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + start.Name = xml.Name{Local: "Input"} + + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Label"}, Value: i.Label}) + if i.Type != "" { + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Type"}, Value: i.Type}) + } + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Name"}, Value: i.Name}) + if i.Required { + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Required"}, Value: "true"}) + } + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Value"}, Value: i.Value}) + if i.MinLength > 0 { + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "MinLength"}, Value: fmt.Sprintf("%d", i.MinLength)}) + } + + if err := e.EncodeToken(start); err != nil { + return nil + } + + if i.Error != "" { + errorStart := xml.StartElement{Name: xml.Name{Local: "Error"}} + if err := e.EncodeElement(i.Error, errorStart); err != nil { + return err + } + } + + if err := e.EncodeToken(start.End()); err != nil { + return err + } + + return nil +} + +func (p *Input) Validate() bool { + if p.Required && p.Value == "" { + p.Error = fmt.Sprintf("%v is required", p.Name) + return false + } + + value_len := len(p.Value) + if p.MinLength > 0 && int(p.MinLength) > value_len { + p.Error = fmt.Sprintf("%v requires at least %v characters (currently %v characters)", p.Name, p.MinLength, value_len) + return false + } + + return true +} diff --git a/http/props/htmlx/link.go b/http/props/htmlx/link.go new file mode 100644 index 0000000..eaf7970 --- /dev/null +++ b/http/props/htmlx/link.go @@ -0,0 +1,24 @@ +package htmlx + +import "encoding/xml" + +type Link struct { + Href string + Name string +} + +func (i *Link) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + start.Name = xml.Name{Local: "A"} + + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Href"}, Value: i.Href}) + + if err := e.EncodeToken(start); err != nil { + return err + } + + if err := e.EncodeToken(xml.CharData(i.Name)); err != nil { + return err + } + + return e.EncodeToken(start.End()) +} diff --git a/http/props/htmlx/submit.go b/http/props/htmlx/submit.go new file mode 100644 index 0000000..86be823 --- /dev/null +++ b/http/props/htmlx/submit.go @@ -0,0 +1,36 @@ +package htmlx + +import ( + "encoding/xml" +) + +type Submit struct { + Label string + Name string `json:",omitempty"` + Value string `json:",omitempty"` +} + +func (i Submit) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + start.Name = xml.Name{Local: "Submit"} + + if i.Name != "" { + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Name"}, Value: i.Name}) + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Value"}, Value: i.Value}) + } else if i.Value != "" { + start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Value"}, Value: i.Value}) + } + + if err := e.EncodeToken(start); err != nil { + return nil + } + + if err := e.EncodeToken(xml.CharData(i.Label)); err != nil { + return err + } + + if err := e.EncodeToken(start.End()); err != nil { + return err + } + + return nil +} diff --git a/http/props/login.go b/http/props/login.go new file mode 100644 index 0000000..868f576 --- /dev/null +++ b/http/props/login.go @@ -0,0 +1,54 @@ +package props + +import ( + "lishwist/http/props/htmlx" +) + +type Login struct { + GeneralError string `json:",omitempty" xml:",omitempty"` + SuccessfulRegistration bool `json:",omitempty" xml:",omitempty"` + SuccessfulSetPassword bool `json:",omitempty" xml:",omitempty"` + Username htmlx.Input + Password htmlx.Input + RegisterLink htmlx.Link + Submit htmlx.Submit +} + +func NewLogin(username, password string) *Login { + return &Login{ + Username: htmlx.Input{ + Label: "Username", + Name: "username", + Required: true, + Value: username, + }, + Password: htmlx.Input{ + Label: "Password", + Name: "password", + Type: "password", + Required: true, + Value: password, + }, + RegisterLink: htmlx.Link{ + Name: "Register", + Href: "/register", + }, + Submit: htmlx.Submit{ + Label: "Login", + }, + } +} + +func (p *Login) Validate() (valid bool) { + valid = true + + if !p.Username.Validate() { + valid = false + } + + if !p.Password.Validate() { + valid = false + } + + return +} diff --git a/http/props/register.go b/http/props/register.go new file mode 100644 index 0000000..4253231 --- /dev/null +++ b/http/props/register.go @@ -0,0 +1,63 @@ +package props + +import ( + "lishwist/http/props/htmlx" + "lishwist/http/templates" +) + +type Register struct { + Navbar templates.NavCollapse + GeneralError string `json:",omitempty"` + Username htmlx.Input + Password htmlx.Input + ConfirmPassword htmlx.Input +} + +func (p *Register) Validate() (valid bool) { + valid = true + + if p.Password.Value != p.ConfirmPassword.Value { + p.ConfirmPassword.Error = "Passwords didn't match" + valid = false + } + + if !p.Username.Validate() { + valid = false + } + + if !p.Password.Validate() { + valid = false + } + + if !p.ConfirmPassword.Validate() { + valid = false + } + + return +} + +func NewRegister(usernameVal, passwordVal, confirmPassVal string) *Register { + return &Register{ + Navbar: templates.DefaultNavCollapse(), + GeneralError: "", + Username: htmlx.Input{ + Name: "username", + Required: true, + MinLength: 4, + Value: usernameVal, + }, + Password: htmlx.Input{ + Type: "password", + Name: "newPassword", + Required: true, + MinLength: 5, + Value: passwordVal, + }, + ConfirmPassword: htmlx.Input{ + Type: "password", + Name: "confirmPassword", + Required: true, + Value: confirmPassVal, + }, + } +} diff --git a/http/routing/account.go b/http/routing/account.go index fdbb051..2ba3996 100644 --- a/http/routing/account.go +++ b/http/routing/account.go @@ -5,7 +5,8 @@ import ( "net/http" lishwist "lishwist/core" - "lishwist/http/api" + "lishwist/http/props" + "lishwist/http/props/htmlx" "lishwist/http/response" "lishwist/http/templates" @@ -16,8 +17,8 @@ type AccountProps struct { Navbar templates.NavCollapse GeneralError string `json:",omitempty"` PasswordFromAdmin bool `json:",omitempty"` - Password templates.InputProps - ConfirmPassword templates.InputProps + Password htmlx.Input + ConfirmPassword htmlx.Input } func (p *AccountProps) Validate() (valid bool) { @@ -42,18 +43,18 @@ func (p *AccountProps) Validate() (valid bool) { func NewAccountProps(username string, passwordFromAdmin bool, passwordVal, confirmPassVal string) *AccountProps { return &AccountProps{ Navbar: templates.NavCollapse{ - Links: []templates.Link{{Href: "/", Name: "Home"}}, + Links: []htmlx.Link{{Href: "/", Name: "Home"}}, User: &templates.User{Name: username}, }, PasswordFromAdmin: passwordFromAdmin, - Password: templates.InputProps{ + Password: htmlx.Input{ Type: "password", Name: "new_password", Required: true, MinLength: 5, Value: passwordVal, }, - ConfirmPassword: templates.InputProps{ + ConfirmPassword: htmlx.Input{ Type: "password", Name: "confirm_password", Required: true, @@ -93,27 +94,27 @@ func AccountPost(app *lishwist.Session, session *response.Session, h http.Header newPassword := r.Form.Get("new_password") confirmPassword := r.Form.Get("confirm_password") - props := NewAccountProps(user.Name, user.PasswordFromAdmin, newPassword, confirmPassword) + account := NewAccountProps(user.Name, user.PasswordFromAdmin, newPassword, confirmPassword) - valid := props.Validate() - props.Password.Value = "" - props.ConfirmPassword.Value = "" + valid := account.Validate() + account.Password.Value = "" + account.ConfirmPassword.Value = "" if !valid { - log.Printf("Invalid account props: %#v\n", props) - session.FlashSet(&props) - return rsvp.SeeOther("/account", props) + log.Printf("Invalid account submission: %#v\n", account) + session.FlashSet(&account) + return rsvp.SeeOther("/account", account) } err = user.SetPassword(newPassword) if err != nil { - props.GeneralError = "Something went wrong." + account.GeneralError = "Something went wrong." log.Printf("Set password failed: %s\n", err) - session.FlashSet(&props) - return rsvp.SeeOther("/account", props) + session.FlashSet(&account) + return rsvp.SeeOther("/account", account) } session.RemoveValue("sessionKey") - session.FlashSet(&api.LoginProps{SuccessfulSetPassword: true}) + session.FlashSet(&props.Login{SuccessfulSetPassword: true}) return rsvp.SeeOther("/", "Set password successful!") } diff --git a/http/routing/login.go b/http/routing/login.go index c41043a..b938608 100644 --- a/http/routing/login.go +++ b/http/routing/login.go @@ -7,29 +7,31 @@ import ( "time" lishwist "lishwist/core" - "lishwist/http/api" + "lishwist/http/props" + "lishwist/http/props/htmlx" "lishwist/http/response" "github.com/Teajey/rsvp" ) func Login(s *response.Session, h http.Header, r *http.Request) rsvp.Response { - props := api.NewLoginProps("", "") + login := props.NewLogin("", "") flash := s.FlashGet() - flashProps, ok := flash.(*api.LoginProps) + flashProps, ok := flash.(*props.Login) if ok { - props.Username.Value = flashProps.Username.Value + login.Username.Value = flashProps.Username.Value - props.GeneralError = flashProps.GeneralError - props.Username.Error = flashProps.Username.Error - props.Password.Error = flashProps.Password.Error + login.GeneralError = flashProps.GeneralError + login.Username.Error = flashProps.Username.Error + login.Password.Error = flashProps.Password.Error - props.SuccessfulRegistration = flashProps.SuccessfulRegistration - props.SuccessfulSetPassword = flashProps.SuccessfulSetPassword + login.SuccessfulRegistration = flashProps.SuccessfulRegistration + login.SuccessfulSetPassword = flashProps.SuccessfulSetPassword } - return rsvp.Response{TemplateName: "login.gotmpl", Body: props} + body := htmlx.Form{Method: "POST", Content: login} + return rsvp.Response{TemplateName: "login.gotmpl", Body: body} } func LoginPost(session *response.Session, h http.Header, r *http.Request) rsvp.Response { @@ -44,15 +46,16 @@ func LoginPost(session *response.Session, h http.Header, r *http.Request) rsvp.R password = r.Form.Get("password") } - props := api.NewLoginProps(username, password) + login := props.NewLogin(username, password) - resp := rsvp.SeeOther(r.URL.Path, props) + resp := rsvp.SeeOther(r.URL.Path, login) - valid := props.Validate() - props.Password.Value = "" + valid := login.Validate() + login.Password.Value = "" if !valid { - session.FlashSet(&props) - log.Printf("Invalid props: %#v\n", props) + session.FlashSet(&login) + log.Printf("Invalid login submission: %#v\n", login) + resp.Body = htmlx.Form{Method: "POST", Content: login} return resp } @@ -61,14 +64,16 @@ func LoginPost(session *response.Session, h http.Header, r *http.Request) rsvp.R var targ lishwist.ErrorInvalidCredentials switch { case errors.As(err, &targ): - props.GeneralError = "Username or password invalid. If you're having trouble accessing your account, you may want to consider asking the System Admin (Thomas) to reset your password" - session.FlashSet(&props) - log.Printf("Invalid credentials: %s: %#v\n", err, props) + login.GeneralError = "Username or password invalid. If you're having trouble accessing your account, you may want to consider asking the System Admin (Thomas) to reset your password" + session.FlashSet(&login) + log.Printf("Invalid credentials: %s: %#v\n", err, login) + resp.Body = htmlx.Form{Method: "POST", Content: login} return resp default: - props.GeneralError = "Something went wrong." - session.FlashSet(&props) + login.GeneralError = "Something went wrong." + session.FlashSet(&login) log.Printf("Login error: %s\n", err) + resp.Body = htmlx.Form{Method: "POST", Content: login} return resp } } diff --git a/http/routing/register.go b/http/routing/register.go index 36dc51a..4b85f49 100644 --- a/http/routing/register.go +++ b/http/routing/register.go @@ -3,7 +3,7 @@ package routing import ( "errors" lishwist "lishwist/core" - "lishwist/http/api" + "lishwist/http/props" "lishwist/http/response" "log" "net/http" @@ -12,20 +12,20 @@ import ( ) func Register(session *response.Session, h http.Header, r *http.Request) rsvp.Response { - props := api.NewRegisterProps("", "", "") + register := props.NewRegister("", "", "") flash := session.FlashGet() - flashProps, _ := flash.(*api.RegisterProps) + flashProps, _ := flash.(*props.Register) if flashProps != nil { - props.Username.Value = flashProps.Username.Value + register.Username.Value = flashProps.Username.Value - props.GeneralError = flashProps.GeneralError - props.Username.Error = flashProps.Username.Error - props.ConfirmPassword.Error = flashProps.ConfirmPassword.Error + register.GeneralError = flashProps.GeneralError + register.Username.Error = flashProps.Username.Error + register.ConfirmPassword.Error = flashProps.ConfirmPassword.Error } - return response.Data("register.gotmpl", props) + return response.Data("register.gotmpl", register) } func RegisterPost(s *response.Session, h http.Header, r *http.Request) rsvp.Response { @@ -44,29 +44,29 @@ func RegisterPost(s *response.Session, h http.Header, r *http.Request) rsvp.Resp confirmPassword = r.Form.Get("confirmPassword") } - props := api.NewRegisterProps(username, newPassword, confirmPassword) + register := props.NewRegister(username, newPassword, confirmPassword) - valid := props.Validate() - props.Password.Value = "" - props.ConfirmPassword.Value = "" + valid := register.Validate() + register.Password.Value = "" + register.ConfirmPassword.Value = "" if !valid { - s.FlashSet(&props) - log.Printf("Invalid register props: %#v\n", props) - return rsvp.SeeOther(r.URL.Path, props) + s.FlashSet(®ister) + log.Printf("Invalid register submission: %#v\n", register) + return rsvp.SeeOther(r.URL.Path, register) } _, err := lishwist.Register(username, newPassword) if err != nil { if errors.Is(err, lishwist.ErrorUsernameTaken) { - props.Username.Error = "Username is taken" + register.Username.Error = "Username is taken" } else { - props.GeneralError = "Something went wrong." + register.GeneralError = "Something went wrong." } - s.FlashSet(&props) + s.FlashSet(®ister) log.Printf("Registration failed: %s\n", err) - return rsvp.SeeOther(r.URL.Path, props) + return rsvp.SeeOther(r.URL.Path, register) } - s.FlashSet(&api.LoginProps{SuccessfulRegistration: true}) + s.FlashSet(&props.Login{SuccessfulRegistration: true}) return rsvp.SeeOther("/", "Registration successful!") } diff --git a/http/server/server.go b/http/server/server.go index f98b9ea..4fe8d70 100644 --- a/http/server/server.go +++ b/http/server/server.go @@ -5,8 +5,8 @@ import ( "net/http" "strings" - "lishwist/http/api" "lishwist/http/env" + "lishwist/http/props" "lishwist/http/response" "lishwist/http/router" "lishwist/http/routing" @@ -30,8 +30,8 @@ func prefixPermanentRedirect(before, after string) response.HandlerFunc { } func Create(useSecureCookies bool) *router.VisibilityRouter { - gob.Register(&api.RegisterProps{}) - gob.Register(&api.LoginProps{}) + gob.Register(&props.Register{}) + gob.Register(&props.Login{}) gob.Register(&routing.AccountProps{}) store := session.NewInMemoryStore([]byte(env.Configuration.SessionSecret)) diff --git a/http/templates/base.gotmpl b/http/templates/base.gotmpl index b41c1d5..65f074e 100644 --- a/http/templates/base.gotmpl +++ b/http/templates/base.gotmpl @@ -1,6 +1,6 @@ {{define "input"}} + value="{{.Value}}" {{if .Required}}required {{end}}{{if .MinLength}}minlength="{{.MinLength}}" {{end}}{{with .Error}} aria-describedby="{{.Name}}Error"{{end}}> {{with .Error}}{{.}}