handleDialEdit handles the "GET /dials/:id/edit" route. This route fetches the underlying dial and renders it in an HTML form.
(w http.ResponseWriter, r *http.Request)
| 208 | // handleDialEdit handles the "GET /dials/:id/edit" route. This route fetches |
| 209 | // the underlying dial and renders it in an HTML form. |
| 210 | func (s *Server) handleDialEdit(w http.ResponseWriter, r *http.Request) { |
| 211 | // Parse dial ID from the path. |
| 212 | id, err := strconv.Atoi(mux.Vars(r)["id"]) |
| 213 | if err != nil { |
| 214 | Error(w, r, wtf.Errorf(wtf.EINVALID, "Invalid ID format")) |
| 215 | return |
| 216 | } |
| 217 | |
| 218 | // Fetch dial from the database. |
| 219 | dial, err := s.DialService.FindDialByID(r.Context(), id) |
| 220 | if err != nil { |
| 221 | Error(w, r, err) |
| 222 | return |
| 223 | } |
| 224 | |
| 225 | // Render dial in the HTML form. |
| 226 | tmpl := html.DialEditTemplate{Dial: dial} |
| 227 | tmpl.Render(r.Context(), w) |
| 228 | } |
| 229 | |
| 230 | // handleDialUpdate handles the "PATCH /dials/:id/edit" route. This route |
| 231 | // reads in the updated fields and issues an update in the database. On success, |
nothing calls this directly
no test coverage detected