Browse Source

En cours de développement

master
losyme 10 months ago
parent
commit
a73f48bd72
  1. 2
      go.mod
  2. 36
      internal/api/api.go
  3. 8
      internal/api/jobs.go
  4. 4
      internal/application/application.go

2
go.mod

@ -13,6 +13,7 @@ require (
forge.chapril.org/losyme/cmdline v0.0.0-20211010173716-509a4c1f872e
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c
forge.chapril.org/losyme/minikit v0.0.0-20211027123940-e67e2d5a7d34
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe
@ -25,7 +26,6 @@ require (
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518 // indirect
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720 // indirect
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae // indirect
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect

36
internal/api/api.go

@ -12,35 +12,57 @@ import (
"forge.chapril.org/eckmuhl/context"
"forge.chapril.org/eckmuhl/middleware"
"forge.chapril.org/eckmuhl/router"
"forge.chapril.org/losyme/logger"
"forge.chapril.org/losyme/uuid"
"forge.chapril.org/dune/dune/internal/components"
)
type api struct {
cs *components.Components
cs *components.Components
logger *logger.Component
}
func new(cs *components.Components) (*api, error) {
logger, err := cs.Logger.New(uuid.New(), "api", cs.Logger.Level())
if err != nil {
return nil, err
}
logger.UseAllOutputs()
api := &api{
cs: cs,
logger: logger,
}
return api, nil
}
func (api *api) status(c *context.Context) error {
return c.JSON(http.StatusOK, nil)
}
func Setup(cs *components.Components) {
api := &api{cs}
func Setup(cs *components.Components) error {
api, err := new(cs)
if err != nil {
return err
}
cs.Router.Use(
middleware.RequestID(),
middleware.Logger(cs.Logger.Component),
middleware.Logger(api.logger),
)
cs.Router.Group("/api", func(g *router.Group) { //api...............................................................
g.Get("/status", api.status)
jobs := &jobs{cs}
g.New("/jobs", func(g2 *router.Group) { //api/jobs..............................................................
g2.Post("", jobs.create)
g2.Post("", api.createJob)
})
})
return nil
}
/*

8
internal/api/jobs.go

@ -10,15 +10,9 @@ import (
"net/http"
"forge.chapril.org/eckmuhl/context"
"forge.chapril.org/dune/dune/internal/components"
)
type jobs struct {
cs *components.Components
}
func (j *jobs) create(c *context.Context) error {
func (api *api) createJob(c *context.Context) error {
return c.JSON(http.StatusCreated, nil)
}

4
internal/application/application.go

@ -71,7 +71,9 @@ func (app *Application) run() error {
return err
}
api.Setup(app.components)
if err := api.Setup(app.components); err != nil {
return err
}
app.components.Scheduler.Start()

Loading…
Cancel
Save