feat: update full url generat
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"quyun/app/models"
|
"quyun/app/models"
|
||||||
|
"quyun/pkg/utils"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -28,7 +29,7 @@ func (f *Middlewares) Auth(ctx fiber.Ctx) error {
|
|||||||
return ctx.Next()
|
return ctx.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fullUrl := string(ctx.Request().URI().FullURI())
|
fullUrl := utils.FullURI(ctx)
|
||||||
u, err := url.Parse(fullUrl)
|
u, err := url.Parse(fullUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"quyun/pkg/utils"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Middlewares) DebugMode(ctx fiber.Ctx) error {
|
func (f *Middlewares) DebugMode(ctx fiber.Ctx) error {
|
||||||
log.Info("------------------")
|
log.Infof("DEBUG: [%s] %s", ctx.Method(), utils.FullURI(ctx))
|
||||||
log.Infof("c.Path: %s", ctx.Path())
|
|
||||||
log.Infof("Request Method: %s", ctx.Method())
|
|
||||||
log.Infof("FullURL: %s", ctx.Request().URI().FullURI())
|
|
||||||
log.Infof("StartPATH: %s", ctx.Params("*"))
|
|
||||||
log.Info("------------------")
|
|
||||||
|
|
||||||
return ctx.Next()
|
return ctx.Next()
|
||||||
}
|
}
|
||||||
|
|||||||
19
backend/pkg/utils/fiber.go
Normal file
19
backend/pkg/utils/fiber.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func FullURI(ctx fiber.Ctx) string {
|
||||||
|
fullURL := string(ctx.Request().URI().FullURI())
|
||||||
|
u, err := url.Parse(fullURL)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
u.Scheme = ctx.Protocol()
|
||||||
|
u.Host = ctx.Host()
|
||||||
|
|
||||||
|
return u.String()
|
||||||
|
}
|
||||||
BIN
backend/quyun
BIN
backend/quyun
Binary file not shown.
Reference in New Issue
Block a user