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

View File

@@ -1,8 +0,0 @@
make app:
curl -H "Content-Type: application/json" -X POST -d '{"name":"myapp","password":"xyz"}' http://localhost:8080/test/1/projects/123/apps
register route:
curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello.rb","image":"treeder/hello.rb", "type":"run"}' http://localhost:8080/test/1/projects/123/apps/myapp/routes
get route:
curl -i -X GET http://localhost:8080/hello.rb?app=myapp

13
tool/README.md Normal file
View File

@@ -0,0 +1,13 @@
# Function Tool
The function tool is a tool to help you build and deploy functions to IronFunctions.
In your projects root folder, run:
```sh
iron build
```
This will iterate through your directories building any changed functions, bumping their version numbers and pushing them to Docker Hub.

1
tool/examples/hello/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/hello

View File

@@ -0,0 +1,7 @@
FROM iron/go:dev
ADD . /go/src/github.com/treeder/hello
WORKDIR /go/src/github.com/treeder/hello
RUN go build github.com/treeder/hello
ENTRYPOINT ["/go/src/github.com/treeder/hello/hello"]

View File

@@ -0,0 +1 @@
0.0.1

View File

@@ -0,0 +1,10 @@
package main
import (
"fmt"
"os"
)
func main() {
fmt.Printf("Hello %v!\n", os.Getenv("PAYLOAD"))
}