|
|
|
# Go Maths students API
|
|
|
|
|
|
|
|
A simple Go API whose only purpose is to check whether an user is a Maths student or not.
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
- An environment variable `AUTHPDS_TOKEN` containing the authentication token for the external API.
|
|
|
|
- An environment variable named `SECRET` containing the secret token for authorization.
|
|
|
|
|
|
|
|
## Docker
|
|
|
|
|
|
|
|
To build and run the image from the provided `Dockerfile`:
|
|
|
|
|
|
|
|
```bash shell
|
|
|
|
$ docker build -t go-maths-api .
|
|
|
|
$ docker run -d --restart always -p 127.235.203.11:1099 --env 'AUTHPDS_TOKEN' --env 'SECRET' --name go-maths-api go-maths-api
|
|
|
|
```
|
|
|
|
|
|
|
|
## Client Usage
|
|
|
|
|
|
|
|
An example request to the local Docker image (with `SECRET` defined in your environment):
|
|
|
|
```
|
|
|
|
curl -X GET "http://asdf:8080/check-maths-user?user=f.minnocci" -H "Authorization: Bearer $SECRET"
|
|
|
|
```
|
|
|
|
|
|
|
|
Successful JSON response:
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"result": true
|
|
|
|
}
|
|
|
|
```
|