feat: update full url generat
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"quyun/app/models"
|
||||
"quyun/pkg/utils"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -28,7 +29,7 @@ func (f *Middlewares) Auth(ctx fiber.Ctx) error {
|
||||
return ctx.Next()
|
||||
}
|
||||
|
||||
fullUrl := string(ctx.Request().URI().FullURI())
|
||||
fullUrl := utils.FullURI(ctx)
|
||||
u, err := url.Parse(fullUrl)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"quyun/pkg/utils"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (f *Middlewares) DebugMode(ctx fiber.Ctx) error {
|
||||
log.Info("------------------")
|
||||
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("------------------")
|
||||
|
||||
log.Infof("DEBUG: [%s] %s", ctx.Method(), utils.FullURI(ctx))
|
||||
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