restendpointhelper.go 351 B

1234567891011121314151617
  1. package utils
  2. import (
  3. "errors"
  4. "net/http"
  5. "github.com/go-chi/chi/v5"
  6. )
  7. // GetURLParam retrieves the specified URL param from a given request.
  8. func GetURLParam(r *http.Request, key string) (value string, err error) {
  9. value = chi.URLParam(r, key)
  10. if value == "" {
  11. err = errors.New("Request does not contain requested URL param")
  12. }
  13. return
  14. }