-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact(docker): changed docker-compose + renamed folders in backend
- Loading branch information
Molaryy
committed
Sep 7, 2024
1 parent
39f0fd8
commit bff1596
Showing
4 changed files
with
53 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package middlewares | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"net/http" | ||
) | ||
|
||
type RegisterInput struct { | ||
Username string `json:"username" binding:"required"` | ||
Password string `json:"password" binding:"required"` | ||
} | ||
|
||
func AuthController(c *gin.Context) { | ||
var input RegisterInput | ||
|
||
if err := c.ShouldBindJSON(&input); err != nil { | ||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
c.JSON(http.StatusOK, gin.H{ | ||
"message": "You just registered", | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package middlewares | ||
|
||
import "github.com/gin-gonic/gin" | ||
|
||
func CORSMiddleware() gin.HandlerFunc { | ||
return func(c *gin.Context) { | ||
c.Writer.Header().Set("Access-Control-Allow-Origin", "*") | ||
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") | ||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") | ||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT, PATCH, DELETE") | ||
|
||
if c.Request.Method == "OPTIONS" { | ||
c.AbortWithStatus(204) | ||
return | ||
} | ||
|
||
c.Next() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.