mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-06 23:28:43 +08:00
update
This commit is contained in:
parent
a973f1d60d
commit
93ab7d55a0
2 changed files with 0 additions and 108 deletions
34
.vscode/auth.go
vendored
34
.vscode/auth.go
vendored
|
@ -1,34 +0,0 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/divyam234/teldrive/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func addAuthRoutes(rg *gin.RouterGroup) {
|
||||
|
||||
r := rg.Group("/auth")
|
||||
|
||||
authService := services.AuthService{SessionCookieName: "__Secure-user-session", SessionMaxAge: 30 * 24 * 60 * 60}
|
||||
|
||||
r.POST("/login", func(c *gin.Context) {
|
||||
|
||||
err := authService.SignIn(c)
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithError(err.Code, err.Error)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
r.GET("/session", func(c *gin.Context) {
|
||||
|
||||
session := authService.GetSession(c)
|
||||
|
||||
c.JSON(http.StatusOK, session)
|
||||
})
|
||||
|
||||
}
|
74
.vscode/file.routes.go
vendored
74
.vscode/file.routes.go
vendored
|
@ -1,74 +0,0 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/divyam234/teldrive/database"
|
||||
"github.com/divyam234/teldrive/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func addFileRoutes(rg *gin.RouterGroup) {
|
||||
|
||||
r := rg.Group("/files")
|
||||
r.Use(Authmiddleware)
|
||||
channelID, _ := strconv.ParseInt(os.Getenv("CHANNEL_ID"), 10, 64)
|
||||
fileService := services.FileService{Db: database.DB, ChannelID: channelID}
|
||||
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
res, err := fileService.ListFiles(c)
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithError(err.Code, err.Error)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
})
|
||||
|
||||
r.POST("/", func(c *gin.Context) {
|
||||
|
||||
res, err := fileService.CreateFile(c)
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithError(err.Code, err.Error)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
})
|
||||
|
||||
r.GET("/:fileID", func(c *gin.Context) {
|
||||
|
||||
res, err := fileService.GetFileByID(c)
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
})
|
||||
|
||||
r.PATCH("/:fileID", func(c *gin.Context) {
|
||||
|
||||
res, err := fileService.UpdateFile(c)
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithError(err.Code, err.Error)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
})
|
||||
|
||||
r.GET("/:fileID/:fileName", func(c *gin.Context) {
|
||||
|
||||
fileService.GetFileStream(context.Background())(c)
|
||||
})
|
||||
|
||||
}
|
Loading…
Reference in a new issue