update: X-Trace-Id

This commit is contained in:
loveuer
2024-07-17 23:05:23 +08:00
parent 116d5b13f8
commit 459e3d9c09
10 changed files with 60 additions and 68 deletions

View File

@ -2,7 +2,9 @@ package api
import (
"context"
"fmt"
"github.com/loveuer/nf"
"github.com/loveuer/nf/nft/resp"
"time"
"ultone/internal/handler"
"ultone/internal/middleware/auth"
@ -21,9 +23,13 @@ func initApp(ctx context.Context) *nf.App {
// todo: add project prefix, if you need
// for example: app := engine.Group("/api/{project}")
app := engine.Group("/api")
app.Get("/available", func(c *nf.Ctx) error {
return c.JSON(nf.Map{"status": 200, "ok": true, "time": time.Now()})
})
app.Get("/available", func() nf.HandlerFunc {
start := time.Now()
return func(c *nf.Ctx) error {
now := time.Now()
return resp.Resp200(c, nf.Map{"ok": true, "start": start, "now": now, "duration": fmt.Sprint(now.Sub(start))})
}
}())
{
api := app.Group("/user")