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())
|
||||
|
|
|
|||
|
|
@ -62,11 +62,8 @@ func NewClientUnix(path string) *Client {
|
|||
}
|
||||
|
||||
func (c *Client) AddJob() (*Job, error) {
|
||||
type request struct {
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
err := json.NewEncoder(&b).Encode(request{})
|
||||
err := json.NewEncoder(&b).Encode(addJobRequest{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
)
|
||||
|
||||
type addJobRequest struct {
|
||||
}
|
||||
|
||||
type addJobResponse struct {
|
||||
ComposeID uuid.UUID `json:"compose_id"`
|
||||
ImageBuildID int `json:"image_build_id"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue