tiny-url-ex/README.md

34 lines
1.3 KiB
Markdown
Raw Normal View History

# xdrm go framework
### 1. Setup
You need a `redis` server running, if you don't have it, you can simply use a docker container for it with `docker run -p 6379:6379 -d redis`.
2018-10-01 19:37:22 +00:00
All commands above must be launched from the root of this repository.
2018-07-07 21:44:42 +00:00
### 2. Build type checkers, controllers, middlewares
2018-10-01 19:37:22 +00:00
Type checkers, controllers and middlewares have to be compiled beforehand. A build command exists for that purpose.
```bash
2018-10-01 19:37:22 +00:00
aicra <project-folder>
```
2018-07-07 21:44:42 +00:00
### 3. Launch the api
```
2018-09-28 14:19:39 +00:00
$ go run ./main.go
2018-10-01 19:37:22 +00:00
```
Now you can play with it with any regular REST API client at `127.0.0.1:4242`.
##### 1. Get an authentication token
- `POST /token/admin` to get an authentication token.
#### 2. Manage tiny urls
> The authentication token must be set inside the `Authorization` header of each request except for the `GET` method.
- `POST /<some-url>` to set a new tiny-url for the url `<some-url>` to redirect to the FORM variable named `target`. Also you can send the FORM data as _x-www-form-urlencoded_, _form-data_ or _json_.
- `PUT /<some-url>` to update an existing tiny-url for the url `<some-url>` to redirect to the FORM variable named `target`.
- `DELETE /<some-url>` to delete the tiny-url for `<some-url>`.
- `GET /<some-url>` to redirect to the target of an existing url `<some-url>.