This recipe shows you how to respond to HTTP requests with a Cloud Function.
View the source code.
-
Follow the Cloud Functions quickstart guide to setup Cloud Functions for your project.
-
Clone this repository:
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git cd nodejs-docs-samples/functions/http -
Create a Cloud Storage Bucket to stage our deployment:
gsutil mb gs://[YOUR_BUCKET_NAME]- Replace
[YOUR_BUCKET_NAME]with the name of your Cloud Storage Bucket.
- Replace
-
Deploy the "helloGET" function with an HTTP trigger
gcloud alpha functions deploy publish --bucket [YOUR_BUCKET_NAME] --trigger-http -
Call the "helloGET" function:
curl https://[YOUR_PROJECT_REGION].[YOUR_PROJECT_ID].cloudfunctions.net/helloGET