Get a URL Parameter from a Request
·
175 words
·
1 minute read
Often it’s important to read off the parameters sent through from the request. If it’s a GET request these will lie within the url itself and can be read using the request’s URL property. It’s important to note that when getting the parameters in this way it will always return an array (or slice?).
Our example below will act a little like an echo server, we listen for any requests and log the result of key
if it’s present.
|
|
Example when calling localhost:8080/?key=hello%20golangcode.com
: