Files
fn-serverless/examples/middleware/README.md
Travis Reeder ce26f665ea Middleware (#502)
* API endpoint extensions working.

extensions example.

extensions example.

* Added server.NewEnv and some docs for the API extensions example.

extensions example.

extensions example.

* Uncommented special handler stuff.

* First example of middleware.

easier to use.

* Added a special Middleware context to make middleware easier to use.

* Fix tests.

* Cleanup based on PR comments.
2017-01-30 23:43:23 +01:00

28 lines
498 B
Markdown

# Middleware Example
This example adds a simple authentication middleware to IronFunctions. See [main.go](main.go) for example code.
## Building and Running
```sh
go build
./middleware
```
Then test with:
```sh
# First, create an app
fn apps create myapp
# And test
curl http://localhost:8080/v1/apps
```
You should get a 401 error.
Add an auth header and it should go through successfully:
```sh
curl -X GET -H "Authorization: Bearer KlaatuBaradaNikto" http://localhost:8080/v1/apps
```