New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify docs for the http key for GCF #5680

Merged
merged 1 commit into from Jan 16, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+9 −2
Diff settings

Always

Just for now

@@ -22,7 +22,7 @@ It might be helpful to read the Google Cloud Functions [HTTP docs](https://cloud


### HTTP endpoint ### HTTP endpoint


This setup specifies that the `first` function should be run when someone accesses the Functions API endpoint via a `GET` request. You can get the URL for the endpoint by running the `serverless info` command after deploying your service. This setup specifies that the `first` function should be run when someone accesses the Functions API endpoint. You can get the URL for the endpoint by running the `serverless info` command after deploying your service.


Here's an example: Here's an example:


@@ -33,7 +33,7 @@ functions:
first: first:
handler: http handler: http
events: events:
- http: path - http: foo # the value of this key is ignored. It is the presence of the http key that matters to serverless.
``` ```


```javascript ```javascript
@@ -45,4 +45,11 @@ exports.first = (request, response) => {
}; };
``` ```


### Differences from other providers

The configuration for Google Cloud Functions is a bit different than some other providers:

* Your deployed endpoint from above will accept GET, POST, and all other HTTP verbs. If you want to disallow certain verbs, [you can do that within the method body](https://cloud.google.com/functions/docs/writing/http#handling_http_methods).
* All Google Cloud Functions are deployed as just the handler name at the root of the URL pathname. In the example above, this means your function is deployed to `https://YOUR_URL/http`. As a result, you cannot configure nested routes such as `http/hello` in your `serverless.yml` file. Instead, Google passes all URLs that appear to be subdirectories of your URL to your handler function so that you can determine the appropriate behavior. The complete path is still available as `req.path` and can be parsed to provide nested routes, path/URL parameters, and more.

**Note:** See the documentation about the [function handlers](../guide/functions.md) to learn how your handler signature should look like to work with this type of event. **Note:** See the documentation about the [function handlers](../guide/functions.md) to learn how your handler signature should look like to work with this type of event.
ProTip! Use n and p to navigate between commits in a pull request.