Added completed user. Some fixes and more more more...
This commit is contained in:
parent
b96dd39795
commit
ea8ab7c0ed
33 changed files with 576 additions and 212 deletions
19
cmd/main.go
19
cmd/main.go
|
|
@ -23,6 +23,7 @@ import (
|
|||
"58team_blog/internal/utils"
|
||||
"log"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -37,12 +38,29 @@ const secret = "58secret"
|
|||
func main() {
|
||||
router := gin.Default()
|
||||
|
||||
// Setup CORS
|
||||
// IMPORTANT: Must be setup before all another middlewares.
|
||||
//cors_config := cors.DefaultConfig()
|
||||
//cors_config.AllowOrigins = []string{"http://localhost:8080", "http://localhost:5173"}
|
||||
//cors_config.AllowAllOrigins = true
|
||||
//cors_config.AllowHeaders = []string{"Origin", "Content-Type", "Accept", "Authorization", "X-Requested-With"}
|
||||
//router.Use(cors.New(cors_config))
|
||||
router.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"http://localhost:5173"},
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
|
||||
AllowHeaders: []string{"*"}, // Пробуем разрешить все заголовки
|
||||
ExposeHeaders: []string{},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 12 * 60 * 60,
|
||||
}))
|
||||
|
||||
// Setup cookie container
|
||||
router.Use(sessions.Sessions("session", cookie.NewStore([]byte(secret))))
|
||||
|
||||
// Register custom validators
|
||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||
v.RegisterValidation("password", utils.PasswordValidator)
|
||||
v.RegisterValidation("inlineList", utils.InlineListValidator)
|
||||
}
|
||||
|
||||
// Swagger setup
|
||||
|
|
@ -78,6 +96,7 @@ func main() {
|
|||
imagesService := services.CreateImagesService(&imagesRepository)
|
||||
|
||||
interfaces.BindPostAdmin(&postService, &userService, g)
|
||||
interfaces.BindPost(&postService, &userService, g)
|
||||
interfaces.BindUser(config.AdminName, config.AdminPassword, &userService, g)
|
||||
interfaces.BindImages(config.ImagesPath, &imagesService, g)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue