Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kelseyhightower committed Apr 10, 2017
1 parent 368c9b2 commit e15e663
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
21 changes: 7 additions & 14 deletions examples/bucket/README.md
Expand Up @@ -2,33 +2,26 @@

## Usage

Build the plugin:
Build the Go plugin:

```
go build -buildmode=plugin -o functions.so examples/bucket/main.go
go build -buildmode=plugin -o functions.so main.go
```

Test the plugin:
Test the function:

```
cat examples/bucket/event.json | \
cloud-functions-go-shim \
-entry-point F \
-event-type bucket \
-plugin-path functions.so
cat event.json | cloud-functions-go-shim -entry-point F -event-type bucket -plugin-path functions.so
```

Create the Google Cloud Function source package:
Create the Cloud Function zip archive:

```
cloud-functions-go \
--entry-point F \
--event-type bucket \
--plugin-path functions.so
cloud-functions-go --entry-point F --event-type bucket --plugin-path functions.so
```

```
wrote F-bucket-1491804101.zip
```

Use the Cloud Function UI to deploy the fuction from a zip file.
Use the Cloud Functions UI to deploy the fuction from a `ZIP upload`, set the fuction to execute to `F`, and the trigger to `Cloud Storage bucket`.
23 changes: 8 additions & 15 deletions examples/http/README.md
@@ -1,42 +1,35 @@
# Google Cloud Functions Go - HTTP Example
# Google Cloud Functions Go: HTTP Example

## Usage

Build the Go plugin:

```
go build -buildmode=plugin -o functions.so examples/http/main.go
go build -buildmode=plugin -o functions.so main.go
```

Test the Go plugin with some test data:
Test the function:

```
cat examples/http/request.json | \
cloud-functions-go-shim \
-entry-point F \
-event-type http \
-plugin-path functions.so
cat request.json | cloud-functions-go-shim -entry-point F -event-type http -plugin-path functions.so
```

> {"body":"{\"message\":\"Go Serverless!\"}\n","header":{"Content-Type":"text/plain; charset=utf-8"},"status_code":200}
### Package
Create the Cloud Function zip archive:

```
cloud-functions-go -o go-serverless.zip \
-entry-point F \
-event-type http \
-plugin-path functions.so
cloud-functions-go -entry-point F -event-type http -plugin-path functions.so
```

Upload the `go-serverless.zip` package the function to execute to `F` and the trigger to `HTTP trigger`.
Use the Cloud Functions UI to deploy the fuction from a `ZIP upload`, set the fuction to execute to `F`, and the trigger to `HTTP trigger`.

Once the function is deployed [invoke it with an HTTP trigger](https://cloud.google.com/functions/docs/calling/http)

Example:

```
curl -X POST https://us-central1-kubestack.cloudfunctions.net/http-test \
curl -X POST https://us-central1-cloud-functions-go.cloudfunctions.net/http-test \
-H "Content-Type: text/plain" \
--data 'Go Serverless!'
```
Expand Down
2 changes: 1 addition & 1 deletion examples/topic/README.md
Expand Up @@ -24,4 +24,4 @@ cloud-functions-go --entry-point F --event-type topic --plugin-path functions.so
wrote F-topic-1491763297.zip
```

Use the Cloud Functions UI to deploy the fuction from a ZIP upload, set the fuction to execute to `F`, and the trigger to `Cloud Pub/Sub topic`
Use the Cloud Functions UI to deploy the fuction from a `ZIP upload`, set the fuction to execute to `F`, and the trigger to `Cloud Pub/Sub topic`.

0 comments on commit e15e663

Please sign in to comment.