detached 5712188

Enable ColorSchemeDetection middleware

commit
5712188e50a164b93a2f7a812f9e2ea54af281de
author
bnema · · 2023-09-05 04:55 UTC
parent
dce1fef
signature
unsigned
6 files · +10 -10
M internal/http/middlewares/detect-color-scheme.go +2 -2
@@ -10,8 +10,8 @@ import (
1010 // ColorSchemeKey is a key for setting and getting the color scheme from the context
1111 const ColorSchemeKey = "CurrentColorScheme"
1212
13-// ColorSchemeDetectionMiddleware detects the current color scheme and sets it in the context
14-func ColorSchemeDetectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
13+// ColorSchemeDetection detects the current color scheme and sets it in the context
14+func ColorSchemeDetection(next echo.HandlerFunc) echo.HandlerFunc {
1515 return func(c echo.Context) error {
1616 colorScheme := detectCurrentColorScheme(c)
1717 fmt.Println("Color scheme detected:", colorScheme)
@@ -10,8 +10,8 @@ import (
10 // ColorSchemeKey is a key for setting and getting the color scheme from the context10 // ColorSchemeKey is a key for setting and getting the color scheme from the context
11 const ColorSchemeKey = "CurrentColorScheme"11 const ColorSchemeKey = "CurrentColorScheme"
12 12
13-// ColorSchemeDetectionMiddleware detects the current color scheme and sets it in the context13+// ColorSchemeDetection detects the current color scheme and sets it in the context
14-func ColorSchemeDetectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {14+func ColorSchemeDetection(next echo.HandlerFunc) echo.HandlerFunc {
15 return func(c echo.Context) error {15 return func(c echo.Context) error {
16 colorScheme := detectCurrentColorScheme(c)16 colorScheme := detectCurrentColorScheme(c)
17 fmt.Println("Color scheme detected:", colorScheme)17 fmt.Println("Color scheme detected:", colorScheme)
M internal/http/middlewares/detect-lang.go +2 -2
@@ -10,8 +10,8 @@ import (
1010 // LangKey is a key for setting and getting the language from the context
1111 const LangKey = "CurrentLang"
1212
13-// LanguageDetectionMiddleware detects the current language and sets it in the context
14-func LanguageDetectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
13+// LanguageDetectiondetects the current language and sets it in the context
14+func LanguageDetection(next echo.HandlerFunc) echo.HandlerFunc {
1515 return func(c echo.Context) error {
1616 lang := detectCurrentLanguage(c)
1717 c.Set(LangKey, lang)
@@ -10,8 +10,8 @@ import (
10 // LangKey is a key for setting and getting the language from the context10 // LangKey is a key for setting and getting the language from the context
11 const LangKey = "CurrentLang"11 const LangKey = "CurrentLang"
12 12
13-// LanguageDetectionMiddleware detects the current language and sets it in the context13+// LanguageDetectiondetects the current language and sets it in the context
14-func LanguageDetectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {14+func LanguageDetection(next echo.HandlerFunc) echo.HandlerFunc {
15 return func(c echo.Context) error {15 return func(c echo.Context) error {
16 lang := detectCurrentLanguage(c)16 lang := detectCurrentLanguage(c)
17 c.Set(LangKey, lang)17 c.Set(LangKey, lang)
M internal/http/middlewares/logger.go +1 -1
@@ -6,7 +6,7 @@ import (
66 "github.com/rs/zerolog"
77 )
88
9-func NewRequestLoggerMiddleware(logger zerolog.Logger) echo.MiddlewareFunc {
9+func NewRequestLogger(logger zerolog.Logger) echo.MiddlewareFunc {
1010 return middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
1111 LogURI: true,
1212 LogStatus: true,
@@ -6,7 +6,7 @@ import (
6 "github.com/rs/zerolog"6 "github.com/rs/zerolog"
7 )7 )
8 8
9-func NewRequestLoggerMiddleware(logger zerolog.Logger) echo.MiddlewareFunc {9+func NewRequestLogger(logger zerolog.Logger) echo.MiddlewareFunc {
10 return middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{10 return middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
11 LogURI: true,11 LogURI: true,
12 LogStatus: true,12 LogStatus: true,
M internal/http/middlewares/secure.go +1 -1
@@ -5,7 +5,7 @@ import (
55 "github.com/labstack/echo/v4/middleware"
66 )
77
8-func SecureMiddleware() echo.MiddlewareFunc {
8+func SecureRoutes() echo.MiddlewareFunc {
99 return middleware.SecureWithConfig(middleware.SecureConfig{
1010 XSSProtection: "1; mode=block",
1111 ContentTypeNosniff: "nosniff",
@@ -5,7 +5,7 @@ import (
5 "github.com/labstack/echo/v4/middleware"5 "github.com/labstack/echo/v4/middleware"
6 )6 )
7 7
8-func SecureMiddleware() echo.MiddlewareFunc {8+func SecureRoutes() echo.MiddlewareFunc {
9 return middleware.SecureWithConfig(middleware.SecureConfig{9 return middleware.SecureWithConfig(middleware.SecureConfig{
10 XSSProtection: "1; mode=block",10 XSSProtection: "1; mode=block",
11 ContentTypeNosniff: "nosniff",11 ContentTypeNosniff: "nosniff",
M internal/http/routes/router.go +4 -3
@@ -11,9 +11,10 @@ func ConfigureRouter(e *echo.Echo, app *app.App) *echo.Echo {
1111 // The logger is already set in main.go, so we don't need to set it again here.
1212
1313 // Register middlewares
14- e.Use(middlewares.NewRequestLoggerMiddleware(app.HTTPLogger.Logger))
15- e.Use(middlewares.LanguageDetectionMiddleware)
16- // e.Use(middlewares.SecureMiddleware()) // Uncomment this line to enable the secure middleware
14+ e.Use(middlewares.NewRequestLogger(app.HTTPLogger.Logger))
15+ e.Use(middlewares.LanguageDetection)
16+ e.Use(middlewares.ColorSchemeDetection)
17+ //e.Use(middlewares.SecureMiddleware()) // Uncomment this line to enable the secure middleware
1718 // Register routes
1819 e = bindStaticAdminUI(e)
1920
@@ -11,9 +11,10 @@ func ConfigureRouter(e *echo.Echo, app *app.App) *echo.Echo {
11 // The logger is already set in main.go, so we don't need to set it again here.11 // The logger is already set in main.go, so we don't need to set it again here.
12 12
13 // Register middlewares13 // Register middlewares
14- e.Use(middlewares.NewRequestLoggerMiddleware(app.HTTPLogger.Logger))14+ e.Use(middlewares.NewRequestLogger(app.HTTPLogger.Logger))
15- e.Use(middlewares.LanguageDetectionMiddleware)15+ e.Use(middlewares.LanguageDetection)
16- // e.Use(middlewares.SecureMiddleware()) // Uncomment this line to enable the secure middleware16+ e.Use(middlewares.ColorSchemeDetection)
17+ //e.Use(middlewares.SecureMiddleware()) // Uncomment this line to enable the secure middleware
17 // Register routes18 // Register routes
18 e = bindStaticAdminUI(e)19 e = bindStaticAdminUI(e)
19 20
D internal/ui/public/tmp/build-errors.log +0 -1
@@ -1,1 +0,0 @@
1-exit status 1⏎̸
@@ -1,1 +0,0 @@
1-exit status 1⏎̸

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close