Browse Source

En cours de développement

master
mls-361 6 months ago
parent
commit
40927a2972
  1. 9
      cmd/main.go
  2. 44
      internal/api/api.go

9
cmd/main.go

@ -16,6 +16,7 @@ import (
"forge.chapril.org/mls-361/application"
"forge.chapril.org/mls-361/failure"
"forge.chapril.org/armen/armen/internal/api"
"forge.chapril.org/armen/armen/internal/cmdline"
"forge.chapril.org/armen/armen/internal/components"
"forge.chapril.org/armen/armen/internal/config"
@ -53,6 +54,8 @@ func createComponents(app components.Application) (components.Logger, components
return nil, nil, failure.Wrap(err, "server") ///////////////////////////////////////////////////////////////////
}
api.Build(router)
return logger, server, nil
}
@ -94,11 +97,15 @@ func run() error {
"name", app.Name(),
"version", app.Version(),
"builtAt", app.BuiltAt().Format("2006-01-02 15:04:05"),
"pid", os.Getpid(),
"pid", syscall.Getpid(),
)
swg := waitEnd(server)
err = server.Start()
if err != nil {
_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
}
swg.Wait()

44
internal/api/api.go

@ -0,0 +1,44 @@
/*
------------------------------------------------------------------------------------------------------------------------
####### api ####### Copyright (c) 2021 mls-361 ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package api
import (
"expvar"
"net/http"
"forge.chapril.org/armen/armen/internal/components"
)
const (
_maxBodySize = 1024 * 4
)
type api struct {
}
func newAPI() *api {
return &api{}
}
func (api *api) createJob(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusOK)
}
func Build(router components.Router) {
api := newAPI()
router.Get("/debug", expvar.Handler())
router.Get("/status", http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
rw.WriteHeader(http.StatusOK)
}))
router.Post("/job/create", http.HandlerFunc(api.createJob))
}
/*
######################################################################################################## @(°_°)@ #######
*/
Loading…
Cancel
Save