VILLASweb-backend-go/routes/file/fileEndpoints.go
Sonja Happ 2e7475a26b - add first draft of code for other routes (not complete!)
- some new endpoints
- some new DB queries
- some new serializers
2019-05-09 17:02:24 +02:00

48 lines
1,014 B
Go

package file
import (
"github.com/gin-gonic/gin"
"net/http"
)
func FilesRegister(r *gin.RouterGroup) {
r.GET("/", filesReadEp)
//r.POST("/", fileRegistrationEp) // TODO to be added to API
//r.PUT("/:FileID", fileUpdateEp) // TODO to be added to API
r.GET("/:FileID", fileReadEp)
r.DELETE("/:FileID", fileDeleteEp)
}
func filesReadEp(c *gin.Context) {
allFiles, _, _ := FindAllFiles()
serializer := FilesSerializerNoAssoc{c, allFiles}
c.JSON(http.StatusOK, gin.H{
"files": serializer.Response(),
})
}
// TODO to be added to API
//func fileRegistrationEp(c *gin.Context) {
// c.JSON(http.StatusOK, gin.H{
// "message": "NOT implemented",
// })
//}
// TODO to be added to API
//func fileUpdateEp(c *gin.Context) {
// c.JSON(http.StatusOK, gin.H{
// "message": "NOT implemented",
// })
//}
func fileReadEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}
func fileDeleteEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}