From ccacd72a362fc84cb1dfa2cdd99317df2d11caef Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 22 Jun 2021 23:43:27 +0200 Subject: [PATCH] feat: handler differentiates missing and invalid parameter --- handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index b6a8b25..d5553c1 100644 --- a/handler.go +++ b/handler.go @@ -2,6 +2,7 @@ package aicra import ( "context" + "errors" "fmt" "net/http" "strings" @@ -37,7 +38,11 @@ func (s Handler) resolve(w http.ResponseWriter, r *http.Request) { // extract request data var input, err = extractInput(service, *r) 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 }