Skip to content

Commit

Permalink
docs: fix exmaple
Browse files Browse the repository at this point in the history
  • Loading branch information
crhntr committed Aug 30, 2024
1 parent 66ac49d commit 2e59e67
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type EditRowPage struct {
}

type EditRow struct {
Value int `input:"count"`
Value int `name:"count"`
}

func (b *Backend) SubmitFormEditRow(fruitID int, form EditRow) EditRowPage {
Expand Down Expand Up @@ -185,12 +185,14 @@ func routes(mux *http.ServeMux, receiver RoutesReceiver) {
id := idParsed
request.ParseForm()
var form EditRow
ValueParsed, err := strconv.Atoi(request.FormValue("count"))
if err != nil {
http.Error(response, err.Error(), http.StatusBadRequest)
return
{
value, err := strconv.Atoi(request.FormValue("count"))
if err != nil {
http.Error(response, err.Error(), http.StatusBadRequest)
return
}
form.Value = value
}
form.Value = ValueParsed
data := receiver.SubmitFormEditRow(id, form)
execute(response, request, true, "PATCH /fruits/{id} SubmitFormEditRow(id, form)", http.StatusOK, data)
})
Expand Down Expand Up @@ -224,5 +226,4 @@ func execute(response http.ResponseWriter, request *http.Request, writeHeader bo
}
_, _ = buf.WriteTo(response)
}

```
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type EditRowPage struct {
}

type EditRow struct {
Value int `input:"count"`
Value int `name:"count"`
}

func (b *Backend) SubmitFormEditRow(fruitID int, form EditRow) EditRowPage {
Expand Down
12 changes: 7 additions & 5 deletions example/template_routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2e59e67

Please sign in to comment.