Browse Source

En cours de développement

master
losyme 5 months ago
parent
commit
2942a21949
  1. 5
      go.sum
  2. 13
      internal/api/api.go
  3. 5
      internal/api/jobs.go

5
go.sum

@ -15,17 +15,12 @@ forge.chapril.org/losyme/crypto v0.0.0-20211213111246-fd5b0716c424 h1:xsqUHX4Cgv
forge.chapril.org/losyme/crypto v0.0.0-20211213111246-fd5b0716c424/go.mod h1:ojbNmqvPUmK6I0sCERfXbLiwHxowyPWDBbjCula7HLw=
forge.chapril.org/losyme/errors v0.0.0-20211213111152-79155957013e h1:2L1MvtJZim7ASkp66uuGhwkrwZoO0zJnfKRDwORv7BM=
forge.chapril.org/losyme/errors v0.0.0-20211213111152-79155957013e/go.mod h1:Gw3DzaKaPGJyh05PqlGNHRmmt14oUaZDoZwdULUlcWQ=
forge.chapril.org/losyme/kong v0.0.0-20211216163507-6ce02b7c7961/go.mod h1:AEC1MI51qHobzM6CwOYASAq8uHnHEo0mkCeY2thXMec=
forge.chapril.org/losyme/kong v0.0.0-20211216170731-bd7ee68a1c19 h1:07opcWPZZzyEhRgziSLIr+A4csY0pXBl26o1H1UmXcs=
forge.chapril.org/losyme/kong v0.0.0-20211216170731-bd7ee68a1c19/go.mod h1:AEC1MI51qHobzM6CwOYASAq8uHnHEo0mkCeY2thXMec=
forge.chapril.org/losyme/kong v0.0.0-20211217171628-71c5c17b842d h1:Xt+nPU6qXoCeFpXvFi46rbwY+LDtNhQAzxtx9oruO9c=
forge.chapril.org/losyme/kong v0.0.0-20211217171628-71c5c17b842d/go.mod h1:AEC1MI51qHobzM6CwOYASAq8uHnHEo0mkCeY2thXMec=
forge.chapril.org/losyme/kvfmt v0.0.0-20211213111132-654025dfe9ec h1:xdWht4Lnz0fz3oUPGE8DikuRn7UH5rkdkBKJbWRfSDw=
forge.chapril.org/losyme/kvfmt v0.0.0-20211213111132-654025dfe9ec/go.mod h1:rmmXkeV+HX8gNdc6zg9H16DJgPopoom39pjmUPIc+B0=
forge.chapril.org/losyme/logger v0.0.0-20211213111305-bb9c37f139f1 h1:tZCKmlcvCd23SfCzXt+lL2qERSdeZgnIGawF7xq0xi0=
forge.chapril.org/losyme/logger v0.0.0-20211213111305-bb9c37f139f1/go.mod h1:XrfI+nPHD+GmeklR9fkbakKKutQa2Evtd/he80pj0sY=
forge.chapril.org/losyme/minikit v0.0.0-20211216163844-8a20ce7276be h1:m3OQOsblAop7ehhanPv3bq2VNQK7EegBRzhFIGU0iiY=
forge.chapril.org/losyme/minikit v0.0.0-20211216163844-8a20ce7276be/go.mod h1:qb15iZQ12xAXPULhKGFQfyeLeuVATjc4a9gDel1zCu0=
forge.chapril.org/losyme/minikit v0.0.0-20211217173301-abde30539e63 h1:5tnucu3f2XgwFhKgTIRhm08utrbr+NH9v7C5/8+sWig=
forge.chapril.org/losyme/minikit v0.0.0-20211217173301-abde30539e63/go.mod h1:D3ujLxRTzLy1poXqLFt68Vm87dkseco4qr2yllpMG80=
forge.chapril.org/losyme/roundrobin v0.0.0-20211213111056-95c0fe446b20/go.mod h1:0YIujnqdL+SQPIRlSzGMBeWpWc4Y44K8aI0x+N+Wydg=

13
internal/api/api.go

@ -12,7 +12,6 @@ import (
"forge.chapril.org/dune/sdk"
"forge.chapril.org/losyme/kong/context"
"forge.chapril.org/losyme/kong/middleware"
"forge.chapril.org/losyme/kong/middleware/json"
"forge.chapril.org/losyme/kong/router"
"forge.chapril.org/losyme/logger"
"forge.chapril.org/losyme/uuid"
@ -34,15 +33,10 @@ func Build(cs *components.Components) (*API, error) {
csr := cs.Router
csr.MethodNotAllowed = json.MethodNotAllowed(logger)
csr.NotFound = json.NotFound(logger)
csr.OnRecover = json.OnRecover(logger)
csr.Use(
middleware.RequestID(),
middleware.Logger(logger),
json.OnError(logger),
json.BasicAuth(cs.Crypto),
middleware.BasicAuth(cs.Crypto),
)
api := &API{
@ -64,7 +58,8 @@ func Build(cs *components.Components) (*API, error) {
}
func (api *API) status(c *context.Context) error {
return c.JSON(http.StatusNoContent, nil)
c.RenderStatusNoContent()
return nil
}
func (api *API) dashboard(c *context.Context) error {
@ -73,7 +68,7 @@ func (api *API) dashboard(c *context.Context) error {
return err
}
return c.JSON(http.StatusOK, stats)
return c.Render(http.StatusOK, stats)
}
/*

5
internal/api/jobs.go

@ -44,10 +44,11 @@ func (api *API) createJob(c *context.Context) error {
}
if job == nil {
return c.JSON(http.StatusNoContent, nil)
c.RenderStatusNoContent()
return nil
}
return c.JSON(http.StatusCreated, job)
return c.Render(http.StatusCreated, job)
}
/*

Loading…
Cancel
Save