-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
setting_get.go
37 lines (32 loc) · 987 Bytes
/
setting_get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package handler
import (
"os"
"github.com/ArtalkJS/Artalk/internal/core"
"github.com/ArtalkJS/Artalk/internal/i18n"
"github.com/ArtalkJS/Artalk/server/common"
"github.com/gofiber/fiber/v2"
)
type ResponseSettingGet struct {
Yaml string `json:"yaml"`
}
// @Id GetSettings
// @Summary Get Settings
// @Description Get settings from app config file
// @Tags System
// @Security ApiKeyAuth
// @Produce json
// @Success 200 {object} ResponseSettingGet
// @Failure 403 {object} Map{msg=string}
// @Failure 500 {object} Map{msg=string}
// @Router /settings [get]
func SettingGet(app *core.App, router fiber.Router) {
router.Get("/settings", common.AdminGuard(app, func(c *fiber.Ctx) error {
dat, err := os.ReadFile(app.Conf().GetCfgFileLoaded())
if err != nil {
return common.RespError(c, 500, i18n.T("Config file read failed"))
}
return common.RespData(c, ResponseSettingGet{
Yaml: string(dat),
})
}))
}