fix validation in request handlers
This commit is contained in:
parent
b434b8a455
commit
5bcfd95cb3
@ -2,7 +2,7 @@ package handlers
|
|||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
func NewDummyHandler() gin.HandlerFunc {
|
func New200OkHandler() gin.HandlerFunc {
|
||||||
return func(ctx *gin.Context) {
|
return func(ctx *gin.Context) {
|
||||||
ctx.Status(200)
|
ctx.Status(200)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,8 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type inputChangePassword struct {
|
type inputChangePassword struct {
|
||||||
OldPassword string `json:"oldPassword"`
|
OldPassword string `json:"oldPassword" binding:"required"`
|
||||||
NewPassword string `json:"newPassword"`
|
NewPassword string `json:"newPassword" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserChangePasswordHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
func NewUserChangePasswordHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
||||||
|
|||||||
@ -10,9 +10,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type createUserInput struct {
|
type createUserInput struct {
|
||||||
Email string `json:"email" validate:"required,email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
Password string `json:"password" validate:"required"`
|
Password string `json:"password" binding:"required"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type createUserOutput struct {
|
type createUserOutput struct {
|
||||||
|
|||||||
@ -10,8 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type loginUserInput struct {
|
type loginUserInput struct {
|
||||||
Login string `json:"email" validate:"required,email"`
|
Login string `json:"email" binding:"required,email"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type loginUserOutput struct {
|
type loginUserOutput struct {
|
||||||
|
|||||||
@ -10,8 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type inputRestorePassword struct {
|
type inputRestorePassword struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token" binding:"required"`
|
||||||
NewPassword string `json:"password"`
|
NewPassword string `json:"password" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserRestorePasswordHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
func NewUserRestorePasswordHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type inputSendRestorePassword struct {
|
type inputSendRestorePassword struct {
|
||||||
Email string `json:"email" validate:"required,email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserSendRestorePasswordHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
func NewUserSendRestorePasswordHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type inputSendVerify struct {
|
type inputSendVerify struct {
|
||||||
Email string `json:"email" validate:"required,email"`
|
Email string `json:"email" binding:"required,email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserSendVerifyEmailHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
func NewUserSendVerifyEmailHandler(log logger.Logger, userService services.UserService) gin.HandlerFunc {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ func NewServer(opts NewServerOpts) *httpserver.Server {
|
|||||||
r.ContextWithFallback = true // Use it to allow getting values from c.Request.Context()
|
r.ContextWithFallback = true // Use it to allow getting values from c.Request.Context()
|
||||||
|
|
||||||
// r.Static("/webapp", "./webapp")
|
// r.Static("/webapp", "./webapp")
|
||||||
r.GET("/health", handlers.NewDummyHandler())
|
r.GET("/health", handlers.New200OkHandler())
|
||||||
|
|
||||||
prometheus := integrations.NewPrometheus()
|
prometheus := integrations.NewPrometheus()
|
||||||
r.Any("/metrics", gin.WrapH(prometheus.GetRequestHandler()))
|
r.Any("/metrics", gin.WrapH(prometheus.GetRequestHandler()))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user