Browse Source

En cours de développement

master
losyme 9 months ago
parent
commit
0c12183a8e
  1. 4
      go.mod
  2. 8
      go.sum
  3. 2
      internal/api/api.go
  4. 26
      internal/api/jobs.go

4
go.mod

@ -10,9 +10,9 @@ require (
forge.chapril.org/losyme/cmdline v0.0.0-20211029192907-e6f74788c44f
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40
forge.chapril.org/losyme/kong v0.0.0-20211028140748-e4aa975543a6
forge.chapril.org/losyme/kong v0.0.0-20211031183030-8c658fa13791
forge.chapril.org/losyme/logger v0.0.0-20211029203543-fbdf72b747cc
forge.chapril.org/losyme/minikit v0.0.0-20211029203831-964ec890a85b
forge.chapril.org/losyme/minikit v0.0.0-20211031183240-ea3671e90f6a
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034
)

8
go.sum

@ -16,14 +16,14 @@ forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720 h1:tMwzjPmGvB
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720/go.mod h1:zSawWghP8cyqaQNOtKBAWGfAeR93uAyHMqpaXtZJsF8=
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40 h1:EoVVFHoIsWRlecHmXP4kx3ALchz5DAfNwso3gcl/Jbk=
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40/go.mod h1:saYfIRBW9zjiCik+/+5ZaajMEnTPBNI00lF9EnO+2kM=
forge.chapril.org/losyme/kong v0.0.0-20211028140748-e4aa975543a6 h1:gOr0gpuR0BLtTtBrwS6bSDd0avNc9Hz1OnZknOHtIU4=
forge.chapril.org/losyme/kong v0.0.0-20211028140748-e4aa975543a6/go.mod h1:sOhHc+IcV5vGNnygTML5/P7Ftmlsf9UB2oL+HQRpsYw=
forge.chapril.org/losyme/kong v0.0.0-20211031183030-8c658fa13791 h1:9H+FbEovrjGuwP1JIDcBAK+dFn6ZHM4sqZduNnPNOkY=
forge.chapril.org/losyme/kong v0.0.0-20211031183030-8c658fa13791/go.mod h1:sOhHc+IcV5vGNnygTML5/P7Ftmlsf9UB2oL+HQRpsYw=
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae h1:RdYWXKy+OQNJueb4Qqqo7sL4OY3/TpfUvmoIoH8ua9E=
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae/go.mod h1:wnVjwnCO2vFLLZ1EgFuFws1n8XLluufsGsdozGYSA7c=
forge.chapril.org/losyme/logger v0.0.0-20211029203543-fbdf72b747cc h1:FKjbR9KbgdEDfx6xATDDrBPA9upTuh22dJ+lB1bmswY=
forge.chapril.org/losyme/logger v0.0.0-20211029203543-fbdf72b747cc/go.mod h1:a3fN8yTjq5S/ramr03hIkutKM/35UsijUgRNKHjjlMU=
forge.chapril.org/losyme/minikit v0.0.0-20211029203831-964ec890a85b h1:OD1EHVjtpE0OF/9C05fd3ZOqcVawKTIoYHaoovN+Kqc=
forge.chapril.org/losyme/minikit v0.0.0-20211029203831-964ec890a85b/go.mod h1:xQLKJWAE7NqbV1frSiizXAcASydOLimWdAqGGbGvmGg=
forge.chapril.org/losyme/minikit v0.0.0-20211031183240-ea3671e90f6a h1:UJnyuQtb9SSCJavW2+YXxu/eeLfHC5+OBxllWLF4VCM=
forge.chapril.org/losyme/minikit v0.0.0-20211031183240-ea3671e90f6a/go.mod h1:Q9/uFzNTZUUaYl8ju+ujVHdOOeu4tj31NasXz9t2b9I=
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf h1:5OIlwVBTdvjCXh2JHAh5rq8FgSe1lXuuKDFtO/ZRaRM=
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf/go.mod h1:VNjFKl0Q2vvLDnR9tdNdTIZDLQNlR+gcIGNf2aIYv3o=
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe h1:xjMUKHxtG8jz57JyOxgNLlRaPLJeQvMV9K3HNlhKDB8=

2
internal/api/api.go

@ -39,7 +39,7 @@ func newAPI(cs *components.Components) (*api, error) {
}
func (api *api) status(c *context.Context) error {
return c.JSON(http.StatusOK, nil)
return c.JSON(http.StatusNoContent, nil)
}
func Setup(cs *components.Components) error {

26
internal/api/jobs.go

@ -7,19 +7,45 @@
package api
import (
"errors"
"net/http"
"forge.chapril.org/dune/jw"
"forge.chapril.org/dune/model"
"forge.chapril.org/losyme/kong"
"forge.chapril.org/losyme/kong/context"
"forge.chapril.org/losyme/kong/decode"
)
func (api *api) createJob(c *context.Context) error {
job := new(jw.Job)
if err := decode.JSON(c, 45, job); err != nil {
return err
}
if job.ID == "" {
job.ID = c.RequestID()
}
job, err := api.cs.Model.CreateJob(job)
if err != nil {
status := http.StatusInternalServerError
if errors.Is(err, model.ErrValidation) {
status = http.StatusBadRequest
}
return &kong.Error{
Status: status,
Message: err.Error(),
}
}
if job == nil {
return c.JSON(http.StatusNoContent, nil)
}
return c.JSON(http.StatusCreated, job)
}

Loading…
Cancel
Save