{{- if ne .Data.Req.Method "POST"}} {{- error 405 "only POST is supported"}} {{- end}} {{- $form := parseForm .Data.Req}} {{- $name := $form.Get "name" | trim}} {{- $content := $form.Get "content"}} {{- if strInRange 1 32 $name | not}}{{error 400 "invalid name length"}}{{end}} {{/* this is dangerous. you should not write to the same directory that the site is in as you could end up accidentally allowing the user to overwrite site contents */}} {{writeFile (osJoinPaths "letters" (stripNonLetters $name)) $content}} {{- redirect 303 "."}}