jobqueue: move remaining request struct to json.go

This commit is contained in:
Lars Karlitski 2020-04-05 08:17:07 +02:00 committed by Tom Gundersen
parent bd4793eb58
commit 4cc459c5cc
3 changed files with 5 additions and 8 deletions

View file

@ -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())