photoprism/internal/api/settings.go
Michael Mayer f88c574f3f Improve HTTP header auth
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2019-11-12 05:49:10 +01:00

37 lines
753 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/config"
)
// GET /api/v1/settings
func GetSettings(router *gin.RouterGroup, conf *config.Config) {
router.GET("/settings", func(c *gin.Context) {
if Unauthorized(c, conf) {
c.AbortWithStatusJSON(http.StatusUnauthorized, ErrUnauthorized)
return
}
result := conf.Settings()
c.JSON(http.StatusOK, result)
})
}
// POST /api/v1/settings
func SaveSettings(router *gin.RouterGroup, conf *config.Config) {
router.POST("/settings", func(c *gin.Context) {
if Unauthorized(c, conf) {
c.AbortWithStatusJSON(http.StatusUnauthorized, ErrUnauthorized)
return
}
// TODO
c.JSON(http.StatusOK, gin.H{"message": "saved"})
})
}