use the ortam config library in the API
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
@ -21,7 +21,7 @@ func admin_log(c *fiber.Ctx, m string) error {
|
||||
func AuthMiddleware(c *fiber.Ctx) error {
|
||||
conf := c.Locals("config").(*config.Type)
|
||||
|
||||
if c.Get("Authorization") != conf.GetStr("password") {
|
||||
if c.Get("Authorization") != conf.Password {
|
||||
return util.ErrAuth(c)
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,7 @@ import (
|
||||
|
||||
func GET_Index(c *fiber.Ctx) error {
|
||||
conf := c.Locals("config").(*config.Type)
|
||||
app := conf.GetURL("app_url")
|
||||
|
||||
// redirect to the API documentation
|
||||
return c.Redirect(app.JoinPath("/doc/api").String())
|
||||
return c.Redirect(conf.AppUrl.JoinPath("/doc/api").String())
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ func GET_News(c *fiber.Ctx) error {
|
||||
|
||||
db := c.Locals("database").(*database.Type)
|
||||
conf := c.Locals("config").(*config.Type)
|
||||
app := conf.GetURL("app_url")
|
||||
lang := c.Params("lang")
|
||||
|
||||
if lang == "" || len(lang) != 2 {
|
||||
@ -63,10 +62,10 @@ func GET_News(c *fiber.Ctx) error {
|
||||
})
|
||||
|
||||
if feed, err = util.Render("views/news.xml", fiber.Map{
|
||||
"app_url": conf.AppUrl,
|
||||
"updated": time.Now().Format(time.RFC3339),
|
||||
"entries": entries,
|
||||
"lang": lang,
|
||||
"app": app,
|
||||
}); err != nil {
|
||||
return util.ErrInternal(c, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user