mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* Remove lots of refs to iron and funcy oracle etc.. * more ref replacements * Replacing more refs. Treeder * Use Fn not FN
28 lines
487 B
Markdown
28 lines
487 B
Markdown
# Middleware Example
|
|
|
|
This example adds a simple authentication middleware to Fn. 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
|
|
```
|