jobqueue: move remaining request struct to json.go
This commit is contained in:
parent
bd4793eb58
commit
4cc459c5cc
3 changed files with 5 additions and 8 deletions
|
|
@ -82,16 +82,13 @@ func statusResponseError(writer http.ResponseWriter, code int, errors ...string)
|
|||
}
|
||||
|
||||
func (api *API) addJobHandler(writer http.ResponseWriter, request *http.Request, _ httprouter.Params) {
|
||||
type requestBody struct {
|
||||
}
|
||||
|
||||
contentType := request.Header["Content-Type"]
|
||||
if len(contentType) != 1 || contentType[0] != "application/json" {
|
||||
statusResponseError(writer, http.StatusUnsupportedMediaType)
|
||||
return
|
||||
}
|
||||
|
||||
var body requestBody
|
||||
var body addJobRequest
|
||||
err := json.NewDecoder(request.Body).Decode(&body)
|
||||
if err != nil {
|
||||
statusResponseError(writer, http.StatusBadRequest, "invalid request: "+err.Error())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue