mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
d2afba465ae892230d6ef33f342c096a2e9378e6
Streams stderr from user functions and outputs a standard format for …
IronFunctions
Quick Start
Start the IronFunctions API
First let's start our IronFunctions API
docker run --rm --privileged -it -e "DB=bolt:///app/data/bolt.db" -v $PWD/data:/app/data -p 8080:8080 iron/functions
This command will quickly start IronFunctions using the default database Bolt running on :8080.
Create an Application
An application is essentially a grouping of functions, that put together, form an API. Here's how to create an app.
curl -H "Content-Type: application/json" -X POST -d '{
"app": { "name":"myapp" }
}' http://localhost:8080/v1/apps
Now that we have an app, we can map routes to functions.
Add a route to a Function
curl -H "Content-Type: application/json" -X POST -d '{
"route": {
"path":"/hello",
"image":"iron/hello"
}
}' http://localhost:8080/v1/apps/myapp/routes
Calling your Function
Just hit the URL you got back from adding a route above:
curl http://localhost:8080/r/myapp/hello
To pass in data to your function
Your function will get the body of the request as is, and the headers of the request will be passed in as env vars. Try this:
curl -H "Content-Type: application/json" -X POST -d '{
"name":"Johnny"
}' http://localhost:8080/r/myapp/hello
Using IronFunctions Hosted by Iron.io
Simply point to https://functions.iron.io instead of localhost and add your Iron.io Authentication header (TODO: link), like this:
curl -H "Authorization: Bearer IRON_TOKEN" -H "Content-Type: application/json" -X POST -d '{"app": {"name":"myapp"}}' https://functions.iron.io/v1/apps
And you'll get an ironfunctions.com host for your app:
myapp.USER_ID.ironfunctions.com/hello
Full Documentation
Join Our Community
Description
Languages
Go
97.4%
Shell
1.2%
Ruby
0.5%
Makefile
0.4%
Dockerfile
0.4%
Other
0.1%