i18n_test.go 473 B

12345678910111213141516171819202122
  1. package i18n
  2. import (
  3. "fmt"
  4. "net/http"
  5. )
  6. func HelloHandlerFunc(w http.ResponseWriter, r *http.Request) {
  7. fmt.Fprintf(w, "Hello, world")
  8. }
  9. // helloHandler implements http.Handler.
  10. type helloHandler struct{}
  11. func (h helloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  12. fmt.Fprintf(w, "Hello, world")
  13. }
  14. func ExampleWithPrinter() {
  15. http.Handle("/h", WithLocalizer(helloHandler{}))
  16. http.Handle("/hf", WithLocalizer(http.HandlerFunc(HelloHandlerFunc)))
  17. }