Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateusoliveira30/crud-in-memory
This is a simple in-memory API for managing users, implemented in Go using the chi framework. The API supports basic CRUD (Create, Read, Update, Delete) operations for users.
https://github.com/mateusoliveira30/crud-in-memory
crud-application golang
Last synced: 4 days ago
JSON representation
This is a simple in-memory API for managing users, implemented in Go using the chi framework. The API supports basic CRUD (Create, Read, Update, Delete) operations for users.
- Host: GitHub
- URL: https://github.com/mateusoliveira30/crud-in-memory
- Owner: MateusOliveira30
- Created: 2024-08-29T12:21:38.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-11T15:29:16.000Z (2 months ago)
- Last Synced: 2024-09-12T00:03:13.722Z (2 months ago)
- Topics: crud-application, golang
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CRUD In-Memory API
This is a simple in-memory API for managing users, implemented in Go using the chi framework. The API supports basic CRUD (Create, Read, Update, Delete) operations for users.
## Project Structure
1. main.go: Entry point of the application.
2. api/: Package containing the API implementation, including handlers and data structures.
## Installation1. Clone the Repository
```
git clone https://github.com/MateusOliveira30/CRUD-In-Memory.git
cd CRUD-In-Memory
```2. Install Dependencies
Make sure you have Go installed and run:
```
go mod tidy
```
3. Running the ServerTo start the server, execute:
```
go run main.go
```The server will be available at http://localhost:8080.
## API Endpoints
1. List All Users
Method: GET
Endpoint: /api/users
Description: Returns all users.
Example Response:```
{
"c11f0bf5-d1de-4782-b625-3efa402d386f": {
"first_name": "Maria",
"last_name": "Mariana",
"biography": "Second user of the application",
"id": "c11f0bf5-d1de-4782-b625-3efa402d386f"
}
}
```2. Get User by ID
Method: GET
Endpoint: /api/users/{id}
Description: Returns a user based on the provided ID.
URL Parameters:id: The ID of the user you want to retrieve.
Example Response:```
{
"first_name": "Maria",
"last_name": "Mariana",
"biography": "Second user of the application",
"id": "c11f0bf5-d1de-4782-b625-3efa402d386f"
}
```3. Create New User
Method: POST
Endpoint: /api/users
Description: Creates a new user.
Request Body:```
{
"first_name": "Maria",
"last_name": "Mariana",
"biography": "New user of the application"
}
```Example Response:
```
{
"id": "c11f0bf5-d1de-4782-b625-3efa402d386f"
}
```4. Update Existing User
Method: PUT
Endpoint: /api/users/{id}
Description: Updates an existing user based on the provided ID.
URL Parameters:id: The ID of the user you want to update.
Request Body:```
{
"first_name": "Maria",
"last_name": "Mariana",
"biography": "Updated biography of Maria Mariana"
}
```Response: 204 No Content (no body)
5. Delete User
Method: DELETE
Endpoint: /api/users/{id}
Description: Deletes a user based on the provided ID.
URL Parameters:id: The ID of the user you want to delete.
Response: 204 No Content (no body)Notes
User data is stored in memory and will be lost when the server is restarted.
The API does not have authentication or authorization, so anyone with access to the server can manipulate the data.