Skip to content

Commit

Permalink
Expose error messages to http response
Browse files Browse the repository at this point in the history
  • Loading branch information
WinPooh32 committed Jan 28, 2023
1 parent 70269fa commit 72b6a2e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions http/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func magnet(next http.Handler) http.Handler {

var magnet, err = metainfo.ParseMagnetUri(magnetURI)
if err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

Expand All @@ -45,12 +45,12 @@ func path(next http.Handler) http.Handler {
var path, err = url.QueryUnescape(chi.URLParam(r, "*"))

if err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

if !govalidator.IsRequestURI("/" + path) {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
http.Error(w, "malformed url", http.StatusBadRequest)
return
}

Expand Down

0 comments on commit 72b6a2e

Please sign in to comment.