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
| @@ -23,10 +23,18 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | |||
| 23 | 23 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | |
| 24 | 24 | github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= | |
| 25 | 25 | github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= | |
| 26 | + | github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= | |
| 27 | + | github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= | |
| 28 | + | github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= | |
| 29 | + | github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= | |
| 30 | + | github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= | |
| 31 | + | github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= | |
| 26 | 32 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | |
| 27 | 33 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | |
| 28 | 34 | github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | |
| 29 | 35 | github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | |
| 36 | + | github.com/labstack/echo-contrib v0.15.0 h1:9K+oRU265y4Mu9zpRDv3X+DGTqUALY6oRHCSZZKCRVU= | |
| 37 | + | github.com/labstack/echo-contrib v0.15.0/go.mod h1:lei+qt5CLB4oa7VHTE0yEfQSEB9XTJI1LUqko9UWvo4= | |
| 30 | 38 | github.com/labstack/echo/v4 v4.11.1 h1:dEpLU2FLg4UVmvCGPuk/APjlH6GDpbEPti61srUUUs4= | |
| 31 | 39 | github.com/labstack/echo/v4 v4.11.1/go.mod h1:YuYRTSM3CHs2ybfrL8Px48bO6BAnYIN4l8wSTMP6BDQ= | |
| 32 | 40 | github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= | |
| @@ -23,10 +23,18 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | |||||
| 23 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | 23 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | ||
| 24 | github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= | 24 | github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= | ||
| 25 | github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= | 25 | github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= | ||
| 26 | + | github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= | |||
| 27 | + | github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= | |||
| 28 | + | github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= | |||
| 29 | + | github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= | |||
| 30 | + | github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= | |||
| 31 | + | github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= | |||
| 26 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | 32 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | ||
| 27 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | 33 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||
| 28 | github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | 34 | github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | ||
| 29 | github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | 35 | github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | ||
| 36 | + | github.com/labstack/echo-contrib v0.15.0 h1:9K+oRU265y4Mu9zpRDv3X+DGTqUALY6oRHCSZZKCRVU= | |||
| 37 | + | github.com/labstack/echo-contrib v0.15.0/go.mod h1:lei+qt5CLB4oa7VHTE0yEfQSEB9XTJI1LUqko9UWvo4= | |||
| 30 | github.com/labstack/echo/v4 v4.11.1 h1:dEpLU2FLg4UVmvCGPuk/APjlH6GDpbEPti61srUUUs4= | 38 | github.com/labstack/echo/v4 v4.11.1 h1:dEpLU2FLg4UVmvCGPuk/APjlH6GDpbEPti61srUUUs4= | ||
| 31 | github.com/labstack/echo/v4 v4.11.1/go.mod h1:YuYRTSM3CHs2ybfrL8Px48bO6BAnYIN4l8wSTMP6BDQ= | 39 | github.com/labstack/echo/v4 v4.11.1/go.mod h1:YuYRTSM3CHs2ybfrL8Px48bO6BAnYIN4l8wSTMP6BDQ= | ||
| 32 | github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= | 40 | github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= | ||
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" | ||