This is a solution for the outdoorsy interview challenge. The application is a REST API that provides endpoints for searching and retrieving rentals.
- Go 1.21.6
- Docker version 24.0.5
- Docker Compose version v2.17.2
- Make 4.3
The application is structured as follows:
.
├── api # swagger api definition and generated models
├── cmd # main entrypoint for the applications
├── internal # private packages
│ ├── configs
│ ├── controllers # http handlers
│ ├── db # database setup
│ ├── models # business models
│ ├── repositories # data access layer
| ├── component_test
│ └── services # business logic
├── Makefile # makefile for running make commands related to the application
The application is configured using environment variables. Copy .env.example
to .env
and edit the values if needed. Database configuration is set in the docker-compose.yml
file.
To run the application, execute the following commands:
make run-db
make run-app
The altomated tests can be run with the following command:
make run-tests
Test coverage can be generated with the following command:
make run-coverage
Here are also some curl commands to test the application manually:
curl --request GET \
--url http://localhost:8181/v1/rentals/1
curl --request GET \
--url http://localhost:8181/v1/rentals/404
curl --request GET \
--url 'http://localhost:8181/v1/rentals?near=33.64%2C-117.93&price_min=9000&price_max=75000&limit=3&offset=3&sort=price'
curl --request GET \
--url 'http://localhost:8181/v1/rentals