This project demonstrates a simple RESTful API written in Go (Golang) using the Gorilla Mux router for handling HTTP requests.
- CRUD Operations: Supports Create, Read, Update, and Delete operations for managing educational records.
- JSON Serialization: Data is exchanged in JSON format between the client and the server.
- Sample Data: Initial sample data for educational records is provided for testing purposes.
- Dynamic ID Generation: IDs for new records are dynamically generated using a random number generator.
- Go (Golang) installed on your system.
github.com/gorilla/mux
package for routing.
-
Clone the repository:
git clone https://github.com/yourusername/your-repo.git
-
Navigate to the project directory:
cd your-repo
-
Install dependencies:
go mod tidy
-
Start the server:
go run main.go
-
The server will start running on port 8081 by default. You can access the API endpoints using tools like cURL or Postman.
GET /educations
: Fetch all educations.GET /educations/{id}
: Fetch an education by ID.POST /educations
: Create a new education.PUT /educations/{id}
: Update an education by ID.DELETE /educations/{id}
: Delete an education by ID.
-
Fetch all educations:
curl http://localhost:8081/educations
-
Fetch a specific education by ID:
curl http://localhost:8081/educations/1
-
Create a new education:
curl -X POST -H "Content-Type: application/json" -d '{"degree":"PhD","gpa":"3.5","student":{"firstname":"John","lastname":"Doe"}}' http://localhost:8081/educations
-
Update an existing education:
curl -X PUT -H "Content-Type: application/json" -d '{"degree":"Bachelor","gpa":"3.2","student":{"firstname":"Alice","lastname":"Smith"}}' http://localhost:8081/educations/1
-
Delete an education:
curl -X DELETE http://localhost:8081/educations/1
This project is licensed under the MIT License - see the LICENSE file for details.