⚡ Generally improves locking and logging
This commit is contained in:
parent
b31382fcda
commit
a23632d5df
10
main.go
10
main.go
@ -58,6 +58,7 @@ func main() {
|
|||||||
|
|
||||||
app := echo.New()
|
app := echo.New()
|
||||||
app.Logger.SetLevel(log.INFO)
|
app.Logger.SetLevel(log.INFO)
|
||||||
|
log.SetLevel(log.INFO)
|
||||||
|
|
||||||
app.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{
|
app.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{
|
||||||
StackSize: 1 << 10,
|
StackSize: 1 << 10,
|
||||||
@ -69,6 +70,7 @@ func main() {
|
|||||||
Format: "${time_custom} ${method} ${uri} ---> ${status} in ${latency_human} (${bytes_out} bytes)\n",
|
Format: "${time_custom} ${method} ${uri} ---> ${status} in ${latency_human} (${bytes_out} bytes)\n",
|
||||||
CustomTimeFormat: TimeFormat,
|
CustomTimeFormat: TimeFormat,
|
||||||
}))
|
}))
|
||||||
|
log.SetHeader("${time_rfc3339} ${level}")
|
||||||
app.Use(middleware.RemoveTrailingSlash())
|
app.Use(middleware.RemoveTrailingSlash())
|
||||||
|
|
||||||
app.OnAddRouteHandler = func(host string, route echo.Route, handler echo.HandlerFunc, middleware []echo.MiddlewareFunc) {
|
app.OnAddRouteHandler = func(host string, route echo.Route, handler echo.HandlerFunc, middleware []echo.MiddlewareFunc) {
|
||||||
@ -141,6 +143,14 @@ func main() {
|
|||||||
return c.NoContent(http.StatusOK)
|
return c.NoContent(http.StatusOK)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
app.GET("/locked", authed(func(c echo.Context) error {
|
||||||
|
mut.Lock()
|
||||||
|
l := locked
|
||||||
|
mut.Unlock()
|
||||||
|
|
||||||
|
return c.JSON(http.StatusOK, l)
|
||||||
|
}))
|
||||||
|
|
||||||
app.POST("/lock", authed(func(c echo.Context) error {
|
app.POST("/lock", authed(func(c echo.Context) error {
|
||||||
mut.Lock()
|
mut.Lock()
|
||||||
locked = true
|
locked = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user