MCPcopy
hub / github.com/benbjohnson/wtf / handleDialEdit

Method handleDialEdit

http/dial.go:210–228  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

208// handleDialEdit handles the "GET /dials/:id/edit" route. This route fetches
209// the underlying dial and renders it in an HTML form.
210func (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,

Callers

nothing calls this directly

Calls 4

ErrorfFunction · 0.92
ErrorFunction · 0.70
FindDialByIDMethod · 0.65
RenderMethod · 0.65

Tested by

no test coverage detected