弹性beantalk上的Golang应用似乎正在接收双重编码的请求

I'm using gorilla/mux inside a Golang application to retrieve variables out of my routes, like so:

func main() {
  router := mux.NewRouter()
  router.HandleFunc("/items/{name}", itemHandler)
  log.Fatal(http.ListenAndServe(":5000", router)
}

func itemHandler(w http.ResponsWriter, r *http.Request) {
  name := mux.Vars(r)["name"]
  fmt.Println("name is: ", name)
}

If I navigate to /items/super%20duper on my local VM the console output is name is: super duper, as I would expect. But when I run this on our Elastic Beanstalk instance and go to the same URL the console output is name is: super%20duper.

We tried changing the proxy_pass entry in the nginx config thinking maybe nginx was not passing the request URI exactly as received, but that had no effect.

If anyone else has seen the same issue I would love to know how you solved it.

You may use func QueryUnescape(s string) (string, error) from "net/url" package:

QueryUnescape:

QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

package main

import (
    "fmt"
    "net/url"
)

func main() {
    s, err := url.QueryUnescape("super%20duper")
    if err != nil {
        panic(err)
    }
    fmt.Println(s) // super duper
}

output:

super duper