command
module
Version:
v0.0.0-...-c812e1d
Opens a new window with list of versions in this module.
Published: May 12, 2024
License: MIT
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Go REST API Boilerplate
Golang API boilerplate using GoFiber, PostgreSQL and Redis
Folder Structure
-
/api/v1
/routes
- All API routes are defined here
/controllers
- For validating requests and calling services
/services
- For business logic, database calls and other services
/middlewares
- For authentication, logging, rate limiting etc.
-
/build
- Contains built binary, gitignore'd
-
/cmd
- Initializes the fiber app and basic middlewares configuration
-
/config
- For handling configuration/env variables
-
/db
- For handling database connections
-
/handlers
- For handling responses and db transactions
-
/models
- GORM Models
-
/types
- For defining custom types that can be used across the app
-
main.go
- Entrypoint of the app
How to use
-
The repo contains product API implementation for reference.
-
Clone the repo and rename the folder to your project name.
-
Search for eleynes/MyK3y
in the project and replace it with <your-github-id/project-name>
.
-
Run go mod tidy
to install all the dependencies.
-
Copy .env.example
to .env
and change the values as per your configuration.
-
Run go build -o ./build/main && ./build/main
to build and run the app.
Optional
-
Run go get github.com/cosmtrek/air
to install air for hot reloading.
-
Run air
to start the app with hot reloading.
Notes
-
Success
Handler for successful requests
-
BuildError
Handler for build errors
-
/api/v1
is the base path for all routes except /
for health check
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.