feat: handler differentiates missing and invalid parameter
This commit is contained in:
parent
3613581b1c
commit
ccacd72a36
|
@ -2,6 +2,7 @@ package aicra
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -37,7 +38,11 @@ func (s Handler) resolve(w http.ResponseWriter, r *http.Request) {
|
||||||
// extract request data
|
// extract request data
|
||||||
var input, err = extractInput(service, *r)
|
var input, err = extractInput(service, *r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newResponse().WithError(api.ErrMissingParam).ServeHTTP(w, r)
|
if errors.Is(err, reqdata.ErrInvalidType) {
|
||||||
|
newResponse().WithError(api.ErrInvalidParam).ServeHTTP(w, r)
|
||||||
|
} else {
|
||||||
|
newResponse().WithError(api.ErrMissingParam).ServeHTTP(w, r)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue