Merge branch 'main' into docker-client
3 files · +20 -0
M go.mod +4 -0
| @@ -21,6 +21,9 @@ require ( | |||
| 21 | 21 | github.com/klauspost/compress v1.16.7 // indirect | |
| 22 | 22 | github.com/moby/patternmatcher v0.6.0 // indirect | |
| 23 | 23 | github.com/moby/sys/sequential v0.5.0 // indirect | |
| 24 | + | github.com/gorilla/context v1.1.1 // indirect | |
| 25 | + | github.com/gorilla/securecookie v1.1.1 // indirect | |
| 26 | + | github.com/gorilla/sessions v1.2.1 // indirect | |
| 24 | 27 | github.com/opencontainers/go-digest v1.0.0 // indirect | |
| 25 | 28 | github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect | |
| 26 | 29 | github.com/opencontainers/runc v1.1.9 // indirect | |
| @@ -35,6 +38,7 @@ require ( | |||
| 35 | 38 | ) | |
| 36 | 39 | ||
| 37 | 40 | require ( | |
| 41 | + | github.com/labstack/echo-contrib v0.15.0 | |
| 38 | 42 | github.com/labstack/gommon v0.4.0 // indirect | |
| 39 | 43 | github.com/mattn/go-colorable v0.1.13 // indirect | |
| 40 | 44 | github.com/mattn/go-isatty v0.0.19 // indirect | |
| @@ -21,6 +21,9 @@ require ( | |||||
| 21 | github.com/klauspost/compress v1.16.7 // indirect | 21 | github.com/klauspost/compress v1.16.7 // indirect | ||
| 22 | github.com/moby/patternmatcher v0.6.0 // indirect | 22 | github.com/moby/patternmatcher v0.6.0 // indirect | ||
| 23 | github.com/moby/sys/sequential v0.5.0 // indirect | 23 | github.com/moby/sys/sequential v0.5.0 // indirect | ||
| 24 | + | github.com/gorilla/context v1.1.1 // indirect | |||
| 25 | + | github.com/gorilla/securecookie v1.1.1 // indirect | |||
| 26 | + | github.com/gorilla/sessions v1.2.1 // indirect | |||
| 24 | github.com/opencontainers/go-digest v1.0.0 // indirect | 27 | github.com/opencontainers/go-digest v1.0.0 // indirect | ||
| 25 | github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect | 28 | github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect | ||
| 26 | github.com/opencontainers/runc v1.1.9 // indirect | 29 | github.com/opencontainers/runc v1.1.9 // indirect | ||
| @@ -35,6 +38,7 @@ require ( | |||||
| 35 | ) | 38 | ) | ||
| 36 | 39 | ||||
| 37 | require ( | 40 | require ( | ||
| 41 | + | github.com/labstack/echo-contrib v0.15.0 | |||
| 38 | github.com/labstack/gommon v0.4.0 // indirect | 42 | github.com/labstack/gommon v0.4.0 // indirect | ||
| 39 | github.com/mattn/go-colorable v0.1.13 // indirect | 43 | github.com/mattn/go-colorable v0.1.13 // indirect | ||
| 40 | github.com/mattn/go-isatty v0.0.19 // indirect | 44 | github.com/mattn/go-isatty v0.0.19 // indirect | ||
M go.sum +8 -0 generated file: collapsed
M internal/http/middlewares/detect-lang.go +8 -0
| @@ -3,6 +3,7 @@ package middlewares | |||
| 3 | 3 | import ( | |
| 4 | 4 | "strings" | |
| 5 | 5 | ||
| 6 | + | "github.com/labstack/echo-contrib/session" | |
| 6 | 7 | "github.com/labstack/echo/v4" | |
| 7 | 8 | ) | |
| 8 | 9 | ||
| @@ -19,6 +20,13 @@ func LanguageDetectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc { | |||
| 19 | 20 | } | |
| 20 | 21 | ||
| 21 | 22 | func detectCurrentLanguage(c echo.Context) string { | |
| 23 | + | // Check if the lang key is set in the session storage | |
| 24 | + | sess, _ := session.Get("session", c) // Assuming you have a session named "session" | |
| 25 | + | if langValue, ok := sess.Values["lang"]; ok { | |
| 26 | + | return langValue.(string) // Return the lang value from the session storage | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | // If lang key is not set, proceed with "Accept-Language" header detection | |
| 22 | 30 | header := c.Request().Header.Get("Accept-Language") | |
| 23 | 31 | if strings.Contains(header, "fr") { | |
| 24 | 32 | return "fr" | |
| @@ -3,6 +3,7 @@ package middlewares | |||||
| 3 | import ( | 3 | import ( | ||
| 4 | "strings" | 4 | "strings" | ||
| 5 | 5 | ||||
| 6 | + | "github.com/labstack/echo-contrib/session" | |||
| 6 | "github.com/labstack/echo/v4" | 7 | "github.com/labstack/echo/v4" | ||
| 7 | ) | 8 | ) | ||
| 8 | 9 | ||||
| @@ -19,6 +20,13 @@ func LanguageDetectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc { | |||||
| 19 | } | 20 | } | ||
| 20 | 21 | ||||
| 21 | func detectCurrentLanguage(c echo.Context) string { | 22 | func detectCurrentLanguage(c echo.Context) string { | ||
| 23 | + | // Check if the lang key is set in the session storage | |||
| 24 | + | sess, _ := session.Get("session", c) // Assuming you have a session named "session" | |||
| 25 | + | if langValue, ok := sess.Values["lang"]; ok { | |||
| 26 | + | return langValue.(string) // Return the lang value from the session storage | |||
| 27 | + | } | |||
| 28 | + | ||||
| 29 | + | // If lang key is not set, proceed with "Accept-Language" header detection | |||
| 22 | header := c.Request().Header.Get("Accept-Language") | 30 | header := c.Request().Header.Get("Accept-Language") | ||
| 23 | if strings.Contains(header, "fr") { | 31 | if strings.Contains(header, "fr") { | ||
| 24 | return "fr" | 32 | return "fr" | ||