// Module included in the following assemblies
//
// * serverless/functions/serverless-developing-go-functions.adoc

:_mod-docs-content-type: REFERENCE
[id="serverless-invoking-go-functions-http_{context}"]
= Functions triggered by an HTTP request

When an incoming HTTP request is received, functions are invoked with a standard Go link:https://golang.org/pkg/context/[Context] as the first parameter, followed by the link:https://golang.org/pkg/net/http/#ResponseWriter[`http.ResponseWriter`] and link:https://golang.org/pkg/net/http/#Request[`http.Request`] parameters. You can use standard Go techniques to access the request, and set a corresponding HTTP response for your function.

.Example HTTP response
[source,go]
----
func Handle(ctx context.Context, res http.ResponseWriter, req *http.Request) {
  // Read body
  body, err := ioutil.ReadAll(req.Body)
  defer req.Body.Close()
  if err != nil {
	http.Error(res, err.Error(), 500)
	return
  }
  // Process body and function logic
  // ...
}
----
