Skip to content

Commit

Permalink
Update readme about webapi
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Jan 21, 2020
1 parent c4e084f commit d1ff9a2
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Expand Up @@ -91,3 +91,53 @@ Or you may use the `serve` command to run the python's builtin wsgi server:
fittonia serve [-b 8080]
```
### WebAPI Usage
First, obtain a token via `fittonia jwt create <payload>` to use web service.
```bash
T=$(fittonia jwt create '{"roles": ["admin"], "name": "yourname"}')
echo $T
```
Then issue a `curl` to create a json resource for example: `/foo':
```bash
curl \
-H"Authorization: $T" \
-H"Content-Type: application/json" \
-X POST \
-d'{"page": "foo"}' \
http://localhost:8080/foo
```
##### GET
Get the `/foo` by:
```bash
curl localhost:8080/foo
```
There are some extra verbs to manage the web resources you already saved:
##### UPDATE
```bash
curl \
-H"Authorization: $T" \
-H"Content-Type: application/json" \
-X UPDATE \
-d'{"page": "foo", "bar": "baz"}' \
http://localhost:8080/foo
```
##### DELETE
```bash
curl \
-H"Authorization: $T" \
-X DELETE \
http://localhost:8080/foo
```

0 comments on commit d1ff9a2

Please sign in to comment.