Starting on some examples to use with function tool.

This commit is contained in:
Travis Reeder
2016-07-17 21:24:50 -07:00
parent 313f56457a
commit a20ad9f4e1
7 changed files with 40 additions and 15 deletions

View File

@@ -13,37 +13,38 @@ docker run --env-file .env --rm -it --privileged -p 8080:8080 iron/functions
## Usage
First things first, create an app/service:
TOOD: App or service??
### Create App
```sh
iron create app APP_NAME
# OR
curl -H "Content-Type: application/json" -X POST -d '{"name":"APP_NAME"}' http://localhost:8080/api/v1/apps
```
### Create a Route
Now add routes to the app. First we'll add a route to the output of a docker container:
```sh
iron add route myapp /hello iron/hello
# OR
curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello", "image":"iron/hello", "type":"run"}' http://localhost:8080/api/v1/apps/myapp/routes
curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello", "image":"iron/hello"}' http://localhost:8080/api/v1/apps/myapp/routes
```
Surf to your function: http://localhost:8080/hello?app=APP_NAME . Boom!
And how about a [slackbot](https://github.com/treeder/slackbots/tree/master/guppy) endpoint:
```sh
curl -H "Content-Type: application/json" -X POST -d '{"path":"/guppy","image":"treeder/guppy:0.0.2", "content_type": "application/json"}' http://localhost:8080/api/v1/apps/myapp/routes
```
Test out the route:
Surf to: http://localhost:8080/hello?app=myapp
You'all also get a custom URL like this when in production.
```
myapp.ironfunctions.com/myroute
APP_NAME.ironfunctions.com/PATH
```
## Updating Your Images