MCPcopy
hub / github.com/knadh/listmonk / hasID

Function hasID

cmd/handlers.go:382–392  ·  view source on GitHub ↗

hasID middleware validates the :id param in the URL and sets its int value in the context.

(next echo.HandlerFunc)

Source from the content-addressed store, hash-verified

380
381// hasID middleware validates the :id param in the URL and sets its int value in the context.
382func hasID(next echo.HandlerFunc) echo.HandlerFunc {
383 return func(c echo.Context) error {
384 id, _ := strconv.Atoi(c.Param("id"))
385 if id < 1 {
386 return echo.NewHTTPError(http.StatusBadRequest, "invalid ID")
387 }
388
389 c.Set("id", id)
390 return next(c)
391 }
392}
393
394// hasSub middleware checks if a subscriber exists given the UUID
395// param in a request.

Callers 1

initHTTPHandlersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected