pcmt/app/startup.go
leo f129606b8f
All checks were successful
continuous-integration/drone/push Build is passing
add bulk changes
* add handlers for signin,singup,logout...
* introduce ent ORM and add user schema
* add live mode, devel mode to selectively turn on features via
  config/flags
* add templates, handle embedding moar smarter:
  * live mode uses live folder structure, else embedded templates are
    used
* start using tailwindcss to style stuff
* add development goodies for hot-reloading (browser-sync - bs.js)
* pimp-up config.dhall with actual custom config Type (enables remote
  schema and local values only as needed)
* add justfile (alternative to makefile for process automation)
2023-04-13 00:07:08 +02:00

53 lines
1.3 KiB
Go

package app
import (
"net/http"
"github.com/labstack/echo/v4/middleware"
)
func (a *App) SetEchoSettings() {
e := a.E()
e.HideBanner = true
e.Use(middleware.Logger())
// e.Use(middleware.LoggerWithConfig(
// middleware.LoggerConfig{
// Format: `{"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}",` +
// `"host":"${host}","method":"${method}","uri":"${uri}","user_agent":"${user_agent}",` +
// `"status":${status},"error":"${error}","latency":${latency},"latency_human":"${latency_human}"` +
// `,"bytes_in":${bytes_in},"bytes_out":${bytes_out}}` + "\n",
// CustomTimeFormat: "2006-01-02 15:04:05.00000",
// },
// ))
// logger := zerolog.New(os.Stdout)
// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
// LogURI: true,
// LogStatus: true,
// LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
// logger.Info().
// Str("URI", v.URI).
// Int("status", v.Status).
// Msg("request")
//
// return nil
// },
// }))
e.Use(middleware.Recover())
// e.Use(middleware.CSRF())
e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
TokenLookup: "cookie:_csrf",
CookiePath: "/",
// CookieDomain: "example.com",
// CookieSecure: true,
CookieHTTPOnly: true,
CookieSameSite: http.SameSiteStrictMode,
}),
)
e.Use(middleware.Secure())
}