https://github.com/reddingg/go-bookshelf
Bookshelf API with Golang (no database)
https://github.com/reddingg/go-bookshelf
exercise golang golang-examples golang-server no-database practice
Last synced: 3 months ago
JSON representation
Bookshelf API with Golang (no database)
- Host: GitHub
- URL: https://github.com/reddingg/go-bookshelf
- Owner: reddingg
- Created: 2023-07-15T15:18:03.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-17T12:15:52.000Z (almost 3 years ago)
- Last Synced: 2024-12-31T10:20:19.954Z (over 1 year ago)
- Topics: exercise, golang, golang-examples, golang-server, no-database, practice
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bookshelf API with Golang Native
This is a RESTful API for storing books with almost zero configuration, as it doesn't integrate with any database. Instead, this backend app utilizes an array to store all data. However, it's important to note that when the web server is turned off, the data will be lost permanently.
## Prerequisites
- Golang
- gorilla/mux package
## Setting Up Project
Please fork this repository first, then clone the repository that you have forked. You can clone your forked repository by using this following command:
```
git clone https://github.com/YOUR GITHUB USERNAME/go-bookshelf.git
```
This project written with native golang programming. No framework used in this project.
To support this application, I use [gorilla/mux](https://github.com/gorilla/mux). Gorilla Mux provides a powerful and flexible routing system, allowing you to define complex URL patterns, handle variables, and extract data from URLs easily. It supports both static and dynamic routing, making it suitable for a wide range of use cases.
Then, open a terminal like bash, zsh, command prompt or powershell and change the directory to where the cloned file is located.
Finally, you can run the API with the following command:
```
go build && ./
```
or
```
go run main.go
```
This project will run on `https://localhost:8080`
## Testing the API
You can try to hit the API using the POSTMAN application.
### API Endpoints
| METHOD | ENDPOINT | FUNCTION |
| -------- | ------------------------ | ----------------------- |
| [GET] | `/api/v1` | to see if the API works |
| [POST] | `/api/v1/book/insert` | insert new book |
| [GET] | `/api/v1/book/show-all` | show all books |
| [GET] | `/api/v1/book/find/{id}` | get book by id |
| [PUT] | `/api/v1/edit/{id}` | edit book by id |
| [DELETE] | `/api/v1/delete{id}` | delete book by id |
### API Payload
```json
{
"title": string,
"author": string,
"publisher": string,
"pageCount": int,
"readPage": int,
}
```