mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
39 lines
616 B
Go
39 lines
616 B
Go
package cosy
|
|
|
|
import (
|
|
"github.com/0xJacky/Nginx-UI/internal/cosy/map2struct"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
func (c *Ctx[T]) Custom(fx func(ctx *Ctx[T])) {
|
|
if c.abort {
|
|
return
|
|
}
|
|
errs := c.validate()
|
|
|
|
if len(errs) > 0 {
|
|
c.ctx.JSON(http.StatusNotAcceptable, gin.H{
|
|
"message": "Requested with wrong parameters",
|
|
"errors": errs,
|
|
})
|
|
return
|
|
}
|
|
|
|
c.beforeDecodeHook()
|
|
|
|
for k := range c.Payload {
|
|
c.SelectedFields = append(c.SelectedFields, k)
|
|
}
|
|
|
|
err := map2struct.WeakDecode(c.Payload, &c.Model)
|
|
|
|
if err != nil {
|
|
errHandler(c.ctx, err)
|
|
return
|
|
}
|
|
|
|
c.beforeExecuteHook()
|
|
|
|
fx(c)
|
|
}
|