Simple Go API to check whether an user is a Math student or not.
  • Go 93.8%
  • Dockerfile 6.2%
Find a file
2023-10-05 19:59:31 +00:00
.env.example varie migliorie 2023-10-01 19:57:34 +02:00
.gitignore varie migliorie 2023-10-01 19:57:34 +02:00
docker-compose.yml Add 'docker-compose.yml' 2023-10-05 19:59:31 +00:00
Dockerfile varie migliorie 2023-10-01 19:57:34 +02:00
go.mod varie migliorie 2023-10-01 19:57:34 +02:00
go.sum varie migliorie 2023-10-01 19:57:34 +02:00
main.go varie migliorie 2023-10-01 19:57:34 +02:00
README.md added some notes in the readme 2023-10-03 14:37:36 +02:00

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.

Development

Development

# Create a ".env" file from the given template and update as needed
$ cp .env.example .env

# Start the server
$ go run -v .

# Build to binary
$ go build -v -o ./bin/go-maths-api .

Deploy

To build and run the image from the provided Dockerfile:

# Create a ".env" file from the given template and update as needed
$ cp .env.example .env

$ docker build -t go-maths-api .
$ docker run -d --restart always -p 8080:8080 --name go-maths-api go-maths-api

Client Usage

An example request to the local Docker image (with SECRET defined in your environment):

$ curl "localhost:8080/check-maths-user?user=f.minnocci" -H "Authorization: Bearer $SECRET"

Successful JSON response:

{
    "result": true
}

Notes