Browse Source

En cours de développement

master
mls-361 1 month ago
parent
commit
9f4d464a34
  1. 22
      internal/api/api.go

22
internal/api/api.go

@ -110,6 +110,27 @@ func (api *api) updateJob(r *jsonapi.Request) {
r.RenderJSON(http.StatusOK, job, api.logger)
}
func (api *api) createWorkflow(r *jsonapi.Request) {
wf := new(jw.Workflow)
if r.Decode(_maxBodySize, wf) != nil {
return
}
wf, err := api.model.CreateWorkflow(wf)
if err != nil {
if errors.Is(err, model.ErrValidation) {
r.BadRequest(err)
} else {
r.InternalServerError(err)
}
return
}
r.RenderJSON(http.StatusCreated, wf, api.logger)
}
func Build(ccs *components.Components) {
api := newAPI(ccs)
router := ccs.Router
@ -121,6 +142,7 @@ func Build(ccs *components.Components) {
router.Post("/job/create", api.debug(api.createJob))
router.Get("/job/next/:namespace", api.trace(api.nextJob))
router.Post("/job/update", api.debug(api.updateJob))
router.Post("/workflow/create", api.debug(api.createWorkflow))
}
/*

Loading…
Cancel
Save