Usage of only proper handler API, no longer need for redundant Context (#2249)

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
This commit is contained in:
Matthias Wessendorf 2024-03-26 13:05:16 +01:00 committed by GitHub
parent 6b78b7f5c5
commit 8ced6269af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 5 deletions

View File

@ -94,16 +94,14 @@ They each will listen and respond to incoming HTTP events.
#### Function triggered by HTTP request
When an incoming request is received, your function will be invoked with a standard
Golang [Context](https://golang.org/pkg/context/) as the first parameter followed by
two parameters: Golang's [http.ResponseWriter](https://golang.org/pkg/net/http/#ResponseWriter)
and [http.Request](https://golang.org/pkg/net/http/#Request).
When an incoming request is received, your function will be invoked with two parameters:
Golang's [http.ResponseWriter](https://golang.org/pkg/net/http/#ResponseWriter) and [http.Request](https://golang.org/pkg/net/http/#Request).
Then you can use standard Golang techniques to access the request (eg. read the body)
and set a proper HTTP response of your function, as you can see on the following example:
```go
func Handle(ctx context.Context, res http.ResponseWriter, req *http.Request) {
func Handle(res http.ResponseWriter, req *http.Request) {
// Read body
body, err := ioutil.ReadAll(req.Body)