https://github.com/saswatamcode/rest_go
A simple RESTful API to create, read, update and delete books built using Go. Uses Mux router.
https://github.com/saswatamcode/rest_go
Last synced: 9 months ago
JSON representation
A simple RESTful API to create, read, update and delete books built using Go. Uses Mux router.
- Host: GitHub
- URL: https://github.com/saswatamcode/rest_go
- Owner: saswatamcode
- License: mit
- Created: 2020-04-11T18:44:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-11T18:47:03.000Z (almost 6 years ago)
- Last Synced: 2025-01-25T16:24:04.440Z (about 1 year ago)
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://opensource.org/licenses/MIT)
[](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)
[](https://GitHub.com/Naereen/ama)
[](https://code.visualstudio.com/)
[](https://GitHub.com/saswatamcode/rest_go/network/)
[](https://GitHub.com/saswatamcode/rest_go/stargazers/)
[](https://GitHub.com/saswatamcode/rest_go/issues/)
[](https://github.com/ellerbrock/open-source-badges/)
# Simple Go REST API
A simple RESTful API to create, read, update and delete books built using Go. Uses Mux router.
## To Run
- Clone into repo
- Run `go get -u github.com/gorilla/mux`
- Run `go run main.go`
- Visit `localhost:8000`
## Endpoints
### Get all books
- `GET /api/books`
### Get a single book
- `GET /api/books/{id}`
### Delete a book
- `DELETE /api/books/{id}`
### Create a book
- `POST /api/books/`
```
{
"isbn":"12345",
"title":"SampleBook",
"author":{"firstname":"John", "lastname":"Doe"}
}
```
### Update a book
- `PUT /api/books/{id}`
```
{
"isbn":"12345",
"title":"SampleBook2",
"author":{"firstname":"John", "lastname":"Doe"}
}
```