init commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"floares/service/auth"
|
||||
"floares/service/containers"
|
||||
"floares/service/images"
|
||||
"floares/service/network"
|
||||
"floares/service/system"
|
||||
"floares/service/volume"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
r.Use(func(c *gin.Context) {
|
||||
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
|
||||
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PATCH")
|
||||
c.Header("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Content-Type,Authorization")
|
||||
c.Header("Access-Control-Expose-Headers", "Content-Length")
|
||||
c.Header("Access-Control-Allow-Credentials", "true")
|
||||
if c.Request.Method == "OPTIONS" {
|
||||
c.Status(http.StatusNoContent)
|
||||
c.Abort()
|
||||
}
|
||||
return
|
||||
|
||||
})
|
||||
a := r.Group("/api/auth")
|
||||
a.POST("/sign-in", auth.Sign)
|
||||
a.GET("/me", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{})
|
||||
})
|
||||
a.POST("/sign-up", auth.Sign)
|
||||
system.RegisterRouter(r.Group("/system"))
|
||||
containers.RegisterRouter(r.Group("/containers"))
|
||||
images.RegisterRouter(r.Group("/images"))
|
||||
network.RegisterRouter(r.Group("/network"))
|
||||
volume.RegisterRouter(r.Group("/volumes"))
|
||||
r.Run()
|
||||
}
|
||||
Reference in New Issue
Block a user