|
@@ -8,6 +8,7 @@ a complete application.
|
|
package ui
|
|
package ui
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "code.osinet.fr/fgm/kurz/web/i18n"
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
"html/template"
|
|
"html/template"
|
|
@@ -82,19 +83,19 @@ func setupAssetRoutes(configAssetsPath string, router *mux.Router) {
|
|
func setupControllerRoutes(gmux *mux.Router) {
|
|
func setupControllerRoutes(gmux *mux.Router) {
|
|
router = *gmux
|
|
router = *gmux
|
|
// BUG(fgm): improve Accept header matchers once https://github.com/golang/go/issues/19307 is completed.
|
|
// BUG(fgm): improve Accept header matchers once https://github.com/golang/go/issues/19307 is completed.
|
|
- gmux.HandleFunc("/{short}", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
+ gmux.Handle("/{short}", i18n.WithPrinter(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
handleGetShort(w, r, gmux)
|
|
handleGetShort(w, r, gmux)
|
|
- }).
|
|
|
|
|
|
+ }))).
|
|
Methods("GET", "HEAD").
|
|
Methods("GET", "HEAD").
|
|
Name(RouteGetShort)
|
|
Name(RouteGetShort)
|
|
- gmux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
+ gmux.Handle("/", i18n.WithPrinter(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
handlePostTarget(w, r, gmux)
|
|
handlePostTarget(w, r, gmux)
|
|
- }).
|
|
|
|
|
|
+ }))).
|
|
HeadersRegexp("Accept", HtmlTypeRegex).
|
|
HeadersRegexp("Accept", HtmlTypeRegex).
|
|
Headers("Content-Type", HtmlFormType).
|
|
Headers("Content-Type", HtmlFormType).
|
|
Methods("POST").
|
|
Methods("POST").
|
|
Name(RoutePostTarget)
|
|
Name(RoutePostTarget)
|
|
- gmux.HandleFunc("/", handleGetRoot).
|
|
|
|
|
|
+ gmux.Handle("/", i18n.WithPrinter(http.HandlerFunc(handleGetRoot))).
|
|
Methods("GET", "HEAD").
|
|
Methods("GET", "HEAD").
|
|
Name(RouteGetRoot)
|
|
Name(RouteGetRoot)
|
|
}
|
|
}
|