Discover Packages
github.com/hsarena/boz
module
Version:
v0.0.0-...-7a189be
Opens a new window with list of versions in this module.
Published: Dec 2, 2023
License: MIT
Opens a new window with license information.
README
README
¶
Boz Projects Documentation
Overview
A REST API project that allows you to manage a herd of sheep. This API provides functionalities for creating sheep entities with attributes such as name, color, wool type, and breed. Additionally, calling the /baa endpoint results in a sheep responding with a cheerful "baa". Dont mind, this is just for fun
API Endpoints
1. Create a Sheep
Endpoint: POST /sheeps
Description: Create a new sheep with attributes such as name, color, wool type, and breed.
Request Payload:
{
"name": "Fluffy",
"color": "White",
"wool": "Carpet",
"breed": "Merino"
}
Example Response:
{
"status": "success",
"sheep": {
"id": 1,
"name": "Fluffy",
"color": "White",
"wool": "Carpet",
"breed": "Merino",
"created_at": "2023-11-20T12:00:00Z"
}
}
2. Get All Sheep
Endpoint: GET /sheeps
Description: Retrieve a list of all sheep in the herd.
Example Response:
{
"status": "success",
"results": 1,
"data": [
{
"id": 1,
"name": "Fluffy",
"color": "White",
"wool": "Carpet",
"breed": "Merino",
"created_at": "2023-11-20T12:00:00Z"
}
]
}
3. Get Sheep by ID
Endpoint: GET /sheeps/:id
Description: Retrieve details of a specific sheep by ID.
Example Response:
{
"status": "success",
"sheep": {
"id": 1,
"name": "Fluffy",
"color": "White",
"wool": "Carpet",
"breed": "Merino",
"created_at": "2023-11-20T12:00:00Z"
}
}
4. Sheep Responds to /baa
Environment Variables
HOST
Description The host where the Boz application will be running.
Value: localhost
Example Usage:
HOST=localhost
PORT
Description: The port on which the Boz application will listen for incoming requests.
Value: 8085
Example Usage:
PORT=8085
DB_USERNAME
Description: The username used to connect to the PostgreSQL database.
Value: boz
Example Usage:
DB_USERNAME=boz
DB_PASSWORD
Description: The password used to authenticate the user connecting to the PostgreSQL database.
Value: bozi
Example Usage:
DB_PASSWORD=bozi
DB_HOSTNAME
Description: The hostname or IP address of the PostgreSQL database server.
Value: localhost
Example Usage:
DB_HOSTNAME=localhost
DB_PORT
Description: The port on which the PostgreSQL database server is listening.
Value: 5432
Example Usage:
DB_PORT=5432
DB_DBNAME
Description: The name of the PostgreSQL database to connect to.
Value: boz
Example Usage:
DB_DBNAME=boz
MIGRATION_PATH
Getting Started
To get started with the Boz application, follow these steps:
Set up your environment variables by creating a .env
file. Example configurations can be found in .env.example
.
Run the Boz application using the main.go
file in the cmd/boz
directory.
go run cmd/boz/main.go
Access the API routes as defined in the routes/sheep.route.go
file.
Notes
The application uses Gin as the web framework.
The database is PostgreSQL, and queries are generated using SQLC.
Configuration management is handled by Viper.
Feel free to explore and customize the code for your specific use case.
If you have any questions or encounter issues, please refer to the documentation of the respective packages used in this project.
Expand ▾
Collapse ▴
Click to show internal directories.
Click to hide internal directories.