Skip to content

Commit

Permalink
add query string example
Browse files Browse the repository at this point in the history
Signed-off-by: Amal Alkhamees <amalkms5@gmail.com>
  • Loading branch information
amalkh5 authored and alexellis committed Apr 4, 2020
1 parent 2dd1099 commit 82a5165
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -301,6 +301,24 @@ func Handle(w http.ResponseWriter, r *http.Request) {
}
```

Example retrieving request query strings

```go
package function
import (
"fmt"
"net/http"
)
func Handle(w http.ResponseWriter, r *http.Request) {
// Parses RawQuery and returns the corresponding
// values as a map[string][]string
// for more info https://golang.org/pkg/net/url/#URL.Query
query := r.URL.Query()
w.WriteHeader(http.StatusOK)
w.Write([]byte(fmt.Sprintf("id: %s", query.Get("id"))))
}
```

#### Advanced usage - Go sub-modules via `GO_REPLACE.txt`

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`.
Expand Down

0 comments on commit 82a5165

Please sign in to comment.