🎉 Inits admin cli app

This commit is contained in:
Daniel Svitan
2025-04-10 22:01:03 +02:00
parent 85a37ef176
commit be9d929309
5 changed files with 167 additions and 6 deletions

View File

@@ -106,7 +106,7 @@ func main() {
app.Use(middleware.Secure())
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: "${time_custom} ${method} ${uri} ---> ${status} in ${latency_human} (${bytes_out} bytes)",
Format: "${time_custom} ${method} ${uri} ---> ${status} in ${latency_human} (${bytes_out} bytes)\n",
CustomTimeFormat: TimeFormat,
}))
app.Use(middleware.RemoveTrailingSlash())
@@ -140,15 +140,17 @@ func main() {
}
}
indent := "\t"
// client connection
app.GET("/", func(c echo.Context) error {
return c.JSON(http.StatusOK, "Hello World!")
return c.JSONPretty(http.StatusOK, "Hello World!", indent)
})
app.GET("/keys", keys)
// administration
app.GET("/admin/clients", authed(func(c echo.Context) error {
return c.JSON(http.StatusOK, clients)
return c.JSONPretty(http.StatusOK, clients, indent)
}))
app.GET("/admin/logs", authed(func(c echo.Context) error {
@@ -162,13 +164,13 @@ func main() {
filenames = append(filenames, file.Name())
}
return c.JSON(http.StatusOK, filenames)
return c.JSONPretty(http.StatusOK, filenames, indent)
}))
app.GET("/admin/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
for _, client := range clients {
if client.ID == id {
return c.JSON(http.StatusOK, client)
return c.JSONPretty(http.StatusOK, client, indent)
}
}
@@ -217,7 +219,7 @@ func main() {
return c.NoContent(http.StatusInternalServerError)
}
return c.JSON(http.StatusOK, bytes)
return c.JSONPretty(http.StatusOK, bytes, indent)
})))
app.POST("/admin/:id/name", authed(idparam(func(c echo.Context, id uuid.UUID) error {