mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 16:56:47 +00:00
Update example for golang-http
Fixes: #1741 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
88eea5f62e
commit
2e14a34243
14
README.md
14
README.md
@ -79,19 +79,21 @@ Official templates exist for many popular languages and are easily extensible wi
|
|||||||
package function
|
package function
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/openfaas-incubator/go-function-sdk"
|
handler "github.com/openfaas/templates-sdk/go-http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Handle a function invocation
|
||||||
func Handle(req handler.Request) (handler.Response, error) {
|
func Handle(req handler.Request) (handler.Response, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
message := fmt.Sprintf("Body: %s", string(req.Body))
|
||||||
|
|
||||||
return handler.Response{
|
return handler.Response{
|
||||||
Body: []byte("Try us out today!"),
|
Body: []byte(message),
|
||||||
Header: map[string][]string{
|
StatusCode: http.StatusOK,
|
||||||
"X-Served-By": []string{"openfaas.com"},
|
|
||||||
},
|
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user