Skip to content

Commit 82a5165

Browse files
amalkh5alexellis
authored andcommitted
add query string example
Signed-off-by: Amal Alkhamees <amalkms5@gmail.com>
1 parent 2dd1099 commit 82a5165

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,24 @@ func Handle(w http.ResponseWriter, r *http.Request) {
301301
}
302302
```
303303

304+
Example retrieving request query strings
305+
306+
```go
307+
package function
308+
import (
309+
"fmt"
310+
"net/http"
311+
)
312+
func Handle(w http.ResponseWriter, r *http.Request) {
313+
// Parses RawQuery and returns the corresponding
314+
// values as a map[string][]string
315+
// for more info https://golang.org/pkg/net/url/#URL.Query
316+
query := r.URL.Query()
317+
w.WriteHeader(http.StatusOK)
318+
w.Write([]byte(fmt.Sprintf("id: %s", query.Get("id"))))
319+
}
320+
```
321+
304322
#### Advanced usage - Go sub-modules via `GO_REPLACE.txt`
305323

306324
For this example you will need to be using Go 1.13 or newer and Go modules, enable this via `faas-cli build --build-arg GO111MODULE=on`.

0 commit comments

Comments
 (0)