A simple RESTful CRUD API built with Go, Gorilla Mux, and JSON.
This project demonstrates how to build a backend API in Go without a database by storing data in memory using slices. It covers all basic CRUD operations:
- Get All Movies
- Get Movie By ID
- Create Movie
- Update Movie
- Delete Movie
- Go
- Gorilla Mux
- REST API
- JSON
- Postman
Returns all available movies.
Endpoint
GET /moviesPostman Response
Returns a single movie using its ID.
Endpoint
GET /movies/{id}Example:
GET /movies/1Postman Response
Creates a new movie.
Endpoint
POST /moviesExample Request Body:
{
"isbn": "41299",
"title": "Better Call Saul",
"director": {
"firstname": "Saul",
"lastname": "Goodman"
}
}Postman Response
Updates an existing movie by ID.
Endpoint
PUT /movies/{id}Example:
PUT /movies/54063039Request Body:
{
"isbn": "438227",
"title": "Breaking Bad",
"director": {
"firstname": "Heisen",
"lastname": "Berg"
}
}Postman Response
Deletes a movie using its ID.
Endpoint
DELETE /movies/{id}Example:
DELETE /movies/99099797Postman Response
Clone the repository:
git clone https://github.com/harshbarnawa/Go-learn.gitNavigate to the project directory:
cd Go-learn/Movie-Crud/src/go-movies-crudInstall dependencies:
go mod tidyRun the server:
go run main.goServer starts on:
http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
| GET | /movies | Get all movies |
| GET | /movies/{id} | Get movie by ID |
| POST | /movies | Create movie |
| PUT | /movies/{id} | Update movie |
| DELETE | /movies/{id} | Delete movie |
Through this project I learned:
- Building REST APIs in Go
- Working with Gorilla Mux
- Handling HTTP Requests & Responses
- JSON Encoding and Decoding
- Route Parameters
- CRUD Operations
- Working with Structs and Pointers
- Testing APIs using Postman
Harsh Barnawa





