Skip to content

Commit

Permalink
Updated the document of examples/error (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunihiko-t authored and c0ze committed Oct 3, 2017
1 parent 4cf3fb7 commit 61daa7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 71 deletions.
9 changes: 0 additions & 9 deletions examples/error/Dockerfile

This file was deleted.

75 changes: 18 additions & 57 deletions examples/error/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,18 @@

This images compares the payload info with the header.

## Requirements

- IronFunctions API

## Development

### Building image locally

```
# SET BELOW TO YOUR DOCKER HUB USERNAME
USERNAME=YOUR_DOCKER_HUB_USERNAME
# build it
./build.sh
```

### Publishing to DockerHub

```
# tagging
docker run --rm -v "$PWD":/app treeder/bump patch
docker tag $USERNAME/func-error:latest $USERNAME/func-error:`cat VERSION`
# pushing to docker hub
docker push $USERNAME/func-error
```

### Testing image

```
./test.sh
# Create your func.yaml file
fn init <YOUR_DOCKERHUB_USERNAME>/func-error
# Build the function
fn build
# Test it
echo '{"input": "yoooo"}' | fn run
# Push it to Docker Hub
fn push
# Create routes to this function on IronFunctions
fn apps create <YOUR_APP>
fn routes create <YOUR_APP> /error
```

## Running it on IronFunctions
Expand All @@ -41,37 +22,17 @@ docker push $USERNAME/func-error

```
# Set your Function server address
# Eg. 127.0.0.1:8080
# Eg.
# FUNCAPI=127.0.0.1:8080
# APPNAME=error
FUNCAPI=YOUR_FUNCTIONS_ADDRESS
APPNAME=YOUR_APP
```

### Running with IronFunctions

With this command we are going to create an application with name `error`.

```
curl -X POST --data '{
"app": {
"name": "error",
}
}' http://$FUNCAPI/v1/apps
```

Now, we can create our route

```
curl -X POST --data '{
"route": {
"image": "'$USERNAME'/func-error",
"path": "/error",
}
}' http://$FUNCAPI/v1/apps/error/routes
```

#### Testing function
### Testing function

Now that we created our IronFunction route, let's test our new route

```
curl -X POST --data '{"input": "yoooo"}' http://$FUNCAPI/r/error/error
```
curl -X POST --data '{"input": "yoooo"}' http://$FUNCAPI/r/$APPNAME/error
```
1 change: 0 additions & 1 deletion examples/error/VERSION

This file was deleted.

4 changes: 0 additions & 4 deletions examples/error/build.sh

This file was deleted.

1 change: 1 addition & 0 deletions examples/error/function.rb → examples/error/func.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require_relative 'bundle/bundler/setup'
require 'json'

payload = STDIN.read
Expand Down

0 comments on commit 61daa7a

Please sign in to comment.