Laura Albert as Mrs. Van Houten in Dr. Caligari (1989)
Matchstick Video!
A Go example API modelling a video rental store.
Status •
Run •
Configuration •
Usage •
Contributing •
License
Status
Matchstick Video is complete. You can run the app, and check the source code to see how I implemented the Clean Architecture in Go.
Run
First you'll need a PostgreSQL DB running. The easiest way is to clone the repo and run docker-compose up -d db
.
Either download a release from the releases page, or clone and run make install
, and execute:
matchstick-video
Or, to run the PostgreSQL DB and the app, clone and run:
make run
Configuration
You can set the following environment variables:
PORT
: What port to run the server on. Defaults to 8080
.
MIGRATION_SOURCE
: Folder which contains DB migrations. Defaults to file://migrations
.
DB_USER
: Username for DB. Defaults to matchvid
.
DB_PASSWORD
: Password for DB. Defaults to password
.
DB_HOST
: Host where the DB can be accessed. Defaults to localhost
.
DB_PORT
: Port where the DB can be accessed. Defaults to 5432
.
DB_NAME
: Name of the database. Defaults to matchvid
.
Usage
Inventory Items
Create
POST on /inventory
Example body:
{
"name": "Cool Runnings (1993)",
"location": "AD12"
}
Example response:
201
: 1
Read one
GET on /inventory/{id}
Example response:
200
:
{
"id": 1,
"name": "Cool Runnings (1993)",
"location": "AD12",
"available": true
}
Read all
GET on /inventory
Example response:
200
:
[
{
"id": 1,
"name": "Cool Runnings (1993)"
},
{
"id": 2,
"name": "The Matrix (1999)"
}
]
Update
PUT on /inventory/{id}
Example body:
{
"name": "Cool Runnings (1993) UPDATED",
"location": "AD12 UPDATED"
}
Example response:
204
Delete
DELETE on /inventory/{id}
Example response:
204
Check out
PUT on /inventory/{id}/checkout
Example response:
204
Check in
PUT on /inventory/{id}/checkin
Example response:
204
Contributing
Please submit an issue with your proposal.
License
See LICENSE