HTTP-based RESTful API written in Golang. Utilizes Postgres and Docker.
- Golang
- Chi
- pgx (Postgres driver library)
- Postgres
- Docker
sudo docker-compose up --build
./curlTest.sh
Before rerunning, make sure to delete the postgres-data/ folder (sudo rm -r -f postgres-data/
)and rerun the docker-compose build command. The testing bash script assumes this is a fresh never-before-used table where the two customer IDs will be 1 and 2.
sudo docker-compose down
{
"name": "James",
"password": "mypassword",
"certificates": []
}
{
"id": 3,
"Active": true,
"privatekey": "helloworld",
"body": "body-of-the-certificate"
}
Note: Certificate ID uniqueness is not checked by the server. When toggling/deleting a certificate, the operation is only performed on the first certificate found with the provided ID.
}
"active": false
}
{
"active": false,
"id": 2
}
Note: A URL may be specified when creating a certificate. This URL will be used whenever the server receives a PUT request to toggle the active status of this certificate. I personally used http://requestb.in/ to confirm functionality of this feature.
base_url/customers/{customer_id}/certificates/{certificate_id}
/customers
- Create a customer
- Delete a customer
/customers/{customer_id}
- Delete a customer
/customers/{customer_id}/certificates
- Get all active certificates for a customer
- Create new certificate
/customers/{customer_id}/certificates/{certificate_id}
- Update active status for a certificate
- main.go - contains main function
- handlers - handlers for http requests
- db.go - functions relating to database access
As the primary purpose of this project was to develop a simple REST API, SQL injection prevention was not a focus. SQL injection prevention would need to be developed if this project were to be intended for production.