En cours de développement

master
losyme 11 months ago
parent 30272b0d0d
commit 78984fd18c
  1. 1
      Taskfile.yml
  2. 1
      go.mod
  3. 2
      go.sum
  4. 13
      kong.go
  5. 5
      middleware/json/json.go
  6. 4
      middleware/middleware.go

@ -7,7 +7,6 @@ tasks:
update:
cmds:
- go get -u forge.chapril.org/losyme/errors
- go get -u forge.chapril.org/losyme/logger
- go get -u forge.chapril.org/losyme/util
- go get -u forge.chapril.org/losyme/uuid
- go mod tidy

@ -4,7 +4,6 @@ go 1.17
require (
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034
)

@ -4,8 +4,6 @@ forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40 h1:EoVVFHoIsW
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40/go.mod h1:saYfIRBW9zjiCik+/+5ZaajMEnTPBNI00lF9EnO+2kM=
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-20211020125912-674a399f933c h1:AsWWDqFMigGp33sHDqGdJVVACiPYcY1ChSmBN7olBrk=
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c/go.mod h1:a3fN8yTjq5S/ramr03hIkutKM/35UsijUgRNKHjjlMU=
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe h1:xjMUKHxtG8jz57JyOxgNLlRaPLJeQvMV9K3HNlhKDB8=
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe/go.mod h1:lKYvkuBOTU3E2HuQZDh4ZSA4u3VcFopQbdPUKaHGHEk=
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034 h1:4NMOPXxwRiXS7wltj2ZZmMO1nFRMPmG1dXK4Ta4MtiM=

@ -6,13 +6,16 @@
package kong
import (
"forge.chapril.org/losyme/logger"
import "forge.chapril.org/losyme/kong/context"
"forge.chapril.org/losyme/kong/context"
)
type Logger interface {
Trace(msg string, kv ...interface{})
Notice(msg string, kv ...interface{})
Warning(msg string, kv ...interface{})
Error(msg string, kv ...interface{})
}
func NoResponse(logger *logger.Component, c *context.Context, err error) {
func NoResponse(logger Logger, c *context.Context, err error) {
logger.Error( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Unable to send a response",
"request", c.RequestID(),

@ -10,7 +10,6 @@ import (
"net/http"
"forge.chapril.org/losyme/errors"
"forge.chapril.org/losyme/logger"
"forge.chapril.org/losyme/kong"
"forge.chapril.org/losyme/kong/context"
@ -18,7 +17,7 @@ import (
"forge.chapril.org/losyme/kong/router"
)
func OnError(logger *logger.Component) router.Middleware {
func OnError(logger kong.Logger) router.Middleware {
return func(next router.HandlerFunc) router.HandlerFunc {
return func(c *context.Context) error {
err := next(c)
@ -54,7 +53,7 @@ func OnError(logger *logger.Component) router.Middleware {
}
}
func NotFound(logger *logger.Component) router.HandlerFunc {
func NotFound(logger kong.Logger) router.HandlerFunc {
return func(c *context.Context) error {
uri := c.Request.URL.RequestURI()

@ -7,16 +7,16 @@
package middleware
import (
"forge.chapril.org/losyme/logger"
"forge.chapril.org/losyme/uuid"
"forge.chapril.org/losyme/kong"
"forge.chapril.org/losyme/kong/context"
"forge.chapril.org/losyme/kong/router"
)
const HeaderXRequestID = "X-Request-ID"
func Logger(logger *logger.Component) router.Middleware {
func Logger(logger kong.Logger) router.Middleware {
return func(next router.HandlerFunc) router.HandlerFunc {
return func(c *context.Context) error {
r := c.Request

Loading…
Cancel
Save