A simple RESTful API built with Go that provides CRUD (Create, Read, Update, Delete) operations for managing a movie collection.
- In-memory data storage for movies
- RESTful API endpoints
- JSON request/response format
- Health check endpoint
- Language: Go 1.25.1
- Router: Gorilla Mux v1.8.1
{
"id": "string",
"idbn": "string",
"title": "string",
"director": {
"firstname": "string",
"lastname": "string"
}
}| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Health check |
| GET | /movies |
Get all movies |
| GET | /movie/{id} |
Get a single movie by ID |
| POST | /movies |
Create a new movie |
| PUT | /movie/{id} |
Update a movie by ID |
| DELETE | /movie/{id} |
Delete a movie by ID |
- Clone the repository:
git clone https://github.com/Flyingmonk01/go-basic-crud.git
cd go-basic-crud- Install dependencies:
go mod download- Run the application:
go run main.goThe server will start on http://localhost:8000
curl http://localhost:8000/curl http://localhost:8000/moviescurl http://localhost:8000/movie/{id}curl -X POST http://localhost:8000/movies \
-H "Content-Type: application/json" \
-d '{
"idbn": "123456",
"title": "Inception",
"director": {
"firstname": "Christopher",
"lastname": "Nolan"
}
}'curl -X PUT http://localhost:8000/movie/{id} \
-H "Content-Type: application/json" \
-d '{
"idbn": "123456",
"title": "Inception Updated",
"director": {
"firstname": "Christopher",
"lastname": "Nolan"
}
}'curl -X DELETE http://localhost:8000/movie/{id}200 OK- Successful GET/PUT request201 Created- Successful POST request204 No Content- Successful DELETE request400 Bad Request- Invalid request body404 Not Found- Movie not found
- Movie IDs are auto-generated using Unix nanosecond timestamps
- Data is stored in-memory and will be lost when the server restarts
- No database persistence is implemented
This project is open source and available for educational purposes.