BAPI or Book-API is a Golang REST API made to show some detail book for person.
| Properties | Description | Type |
|---|---|---|
| judul_buku | the identity title book | String |
| penulis | author book | String |
| tgl_publikasi | date of publication | String |
| Routes | HTTP Methods | Description |
|---|---|---|
| /api/book/ | GET | Displays all book |
| /api/book/ | POST | Creates a new book |
| /api/book/{id} | GET | Displays a specific book, given its name |
| /api/book/{id} | PUT | Update identitiy book |
| /api/user/{id}} | DELETE | Deletes a specific book, given its id |
Project is created with:
- Golang
- gorilla/mux
- lib/pq
- joho/godotenv
- PostgreSQL
To run this project locally, clone repo and add an .env file in the root:
POSTGRES_URL="Postgres connection string"
Then execute in command prompt:
$ cd go-postgres
$ go mod tidy
$ go run main.go
These are the endpoints available from the app
Returns result identity
Show example response
{
"data": [
{
"judul_buku":"Al Wajiz",
"penulis": "Imam Ibnu Taimiyah",
"tgl_publikasi":"2020-10-11",
}
]
}Creates a new identity book
This request requires body payload, you can find the example below.
Show example payload
{
"judul_buku":"Al Wajiz",
"penulis": "Imam Ibnu Taimiyah",
"tgl_publikasi":"2020-10-11",
}Returns a book by id
Show example response
{
"meta": {
"code": 200
},
"data": {
"id": 1,
"judul_buku":"Al Wajiz",
"penulis": "Imam Ibnu Taimiyah",
"tgl_publikasi":"2020-10-11",
}
}Update value of identity book
Show example response
{
"judul_buku":"Al Wajiz",
"penulis": "Imam Ibnu Taimiyah",
"tgl_publikasi":"2020-10-11",
}Delete team by id