Simple ReST API Using Go Lang
- A Simple ReST API using Go Lang
- Mux Router
- Currently data managed from memory
- Add Database Configuration
- Make architecture for Big One
Step 1: Install Go language on your machine.
Step 2: Clone this repository
git clone https://github.com/ManiruzzamanAkash/GoLang-Rest-API.git
Step 3: Go to that project, if you're on another directory.
Rename the folder to something else -
goapi-test
Go to that folder -
cd goapi-test
Step 4: Build App
go build
Step 5: Run
./goapi-test
All Books
URL: http://localhost:8000/api/books
Method: get
Get Single Book URL: http://localhost:8000/api/books/1
Method: get
Create a book -
URL: http://localhost:8000/api/books
Method: post
{
"Title" : "Book Created",
"Isbn": "819289823",
"Author": {
"FirstName": "Maniruzzaman",
"LastName": "Akash"
}
}
Update a Book
URL: http://localhost:8000/api/books/2
Method: put
Where 2
is the ID
{
"Title" : "Book Updated for 2",
"Isbn": "819289823",
"Author": {
"FirstName": "Maniruzzaman",
"LastName": "Akash"
}
}
Delete a Book
URL: http://localhost:8000/api/books/31847
Method: delete
Where 31847
is the ID