Skip to content

Project to show dependency injection with Golang and UberFX

Notifications You must be signed in to change notification settings

Kurukshetran/go-di-webservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go User Management Service

A RESTful user management service built with Go, MongoDB, and Uber Fx for dependency injection.

Features

  • User registration and authentication
  • Password hashing using bcrypt
  • MongoDB for data persistence
  • Dependency injection using Uber Fx
  • RESTful API endpoints for CRUD operations

Prerequisites

  • Go 1.21 or higher
  • MongoDB running on localhost:27017

Installation

  1. Clone the repository:
git clone <repository-url>
cd go-di-webservice
  1. Install dependencies:
go mod tidy
  1. Run the application:
go run main.go

The server will start on http://localhost:8080.

API Endpoints

Create User

POST /users
Content-Type: application/json

{
    "email": "[email protected]",
    "password": "password123",
    "first_name": "John",
    "last_name": "Doe"
}

Get User

GET /users/{id}

Update User

PUT /users/{id}
Content-Type: application/json

{
    "first_name": "John",
    "last_name": "Doe",
    "password": "newpassword" // Optional
}

Delete User

DELETE /users/{id}

Login

POST /users/login
Content-Type: application/json

{
    "email": "[email protected]",
    "password": "password123"
}

Project Structure

.
├── internal/
│   ├── config/      # MongoDB configuration
│   ├── models/      # Data models
│   ├── repositories/# Data access layer
│   ├── services/    # Business logic
│   └── handlers/    # HTTP handlers
├── main.go         # Application entry point
└── README.md

Dependencies

About

Project to show dependency injection with Golang and UberFX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages