only return 400 errors
This commit is contained in:
parent
76633aaf89
commit
cf367b6abd
|
@ -61,7 +61,7 @@ func userWebmentionHandler(repo *owl.Repository) func(http.ResponseWriter, *http
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
user, err := getUserFromRepo(repo, ps)
|
user, err := getUserFromRepo(repo, ps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
w.Write([]byte("User not found"))
|
w.Write([]byte("User not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -105,14 +105,14 @@ func userWebmentionHandler(repo *owl.Repository) func(http.ResponseWriter, *http
|
||||||
|
|
||||||
parts := strings.Split(target[0], "/")
|
parts := strings.Split(target[0], "/")
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
w.Write([]byte("Not found"))
|
w.Write([]byte("Not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
postId := parts[len(parts)-2]
|
postId := parts[len(parts)-2]
|
||||||
post, err := user.GetPost(postId)
|
post, err := user.GetPost(postId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
w.Write([]byte("Post not found"))
|
w.Write([]byte("Post not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ func TestValidationOfTarget(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertStatus(t, rr, http.StatusNotFound)
|
assertStatus(t, rr, http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue