mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Starting on some examples to use with function tool.
This commit is contained in:
15
README.md
15
README.md
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user