This project is a web API developed in Go (Golang) v1.22 for handling HTTP requests. It provides endpoints for managing tasks and utilizes Docker for containerization, making it easy to deploy across different environments. The project follows a clean and organized structure to enhance maintainability and scalability.
- HTTP Server: Implements a robust HTTP server for handling incoming requests.
- Routing: Utilizes a flexible router setup for managing API endpoints efficiently.
- Middleware: Incorporates middleware for handling cross-origin resource sharing (CORS) and logging.
- Database Integration: Supports MongoDB as the backend database for storing task-related information.
- Error Handling: Implements utility functions for generating consistent and informative error responses.
- Platform Independence: Provides binaries for multiple platforms (Windows, Linux, macOS) to ensure compatibility.
.
├── Dockerfile
├── Makefile
├── bin
│ ├── darwin_amd64
│ │ └── image-server
│ ├── linux_amd64
│ │ └── image-server
│ └── windows_amd64
│ └── image-server.exe
├── cmd
│ ├── api
│ │ ├── http-server
│ │ │ └── http.server.go
│ │ ├── router-setup
│ │ │ ├── base.router.go
│ │ │ └── task.router.go
│ │ └── server.go
│ └── main.go
├── docker-compose.yml
├── go.mod
├── go.sum
└── internal
└── application
├── config
│ └── env.go
├── database
│ └── mongodb.go
├── handler
│ └── task.handler.go
├── middleware
│ ├── cors.middleware.go
│ └── logger.middleware.go
├── model
│ ├── base
│ │ └── base.model.go
│ └── task.model.go
├── repository
│ ├── base
│ │ └── base.repository.go
│ └── task.repository.go
├── service
└── utility
└── response.utility.go
- Clone the repository:
Clonehttps://github.com/DevInsightForge/Go-Http-101
- Install Dependencies:
Rungo mod download
. - Build the Application:
Runmake
. - Run the Application:
Execute the appropriate binary for your platform located in thebin
directory.
- Environment Variables:
Update the.env.example
file in theroot
directory to set environment-specific configurations such as database connection details, server port, etc.
- Endpoints:
Define and implement additional endpoints as per the requirements in therouter-setup
directory. - Middleware:
Customize middleware functions in themiddleware
directory to suit specific needs. - Error Handling:
Extend error handling logic in theutility
directory for handling various error scenarios gracefully.
- Fork the repository
- Create a new branch (
git checkout -b feature/feature-name
) - Make changes and commit (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature/feature-name
) - Create a pull request
This project is licensed under the MIT License.
For any inquiries or feedback, please contact Project Maintainer.