52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"floares/lib/libpod"
|
|
"floares/service/auth"
|
|
"floares/service/containers"
|
|
"floares/service/images"
|
|
"floares/service/network"
|
|
"floares/service/system"
|
|
"floares/service/volume"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
|
|
//if reexec.Init() {
|
|
// // We were invoked with a different argv[0] indicating that we
|
|
// // had a specific job to do as a subprocess, and it's done.
|
|
// return
|
|
//}
|
|
//c := cobra.Command{}
|
|
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"))
|
|
libpod.NewServer()
|
|
r.Run()
|
|
}
|