https://github.com/shiponcs/bookstore-api-cpp
https://github.com/shiponcs/bookstore-api-cpp
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/shiponcs/bookstore-api-cpp
- Owner: shiponcs
- Created: 2023-06-07T11:54:37.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-09T04:32:09.000Z (over 2 years ago)
- Last Synced: 2024-12-29T17:44:23.468Z (about 1 year ago)
- Language: C++
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BookStore-api-cpp
Developed using [pistache](https://pistacheio.github.io/pistache/docs/rest-description/) and [rapidjson](https://rapidjson.org/). It uses `basic auth`.
#### Build
```bash
g++ server.cpp base64.cpp -o server -lpistache
```
#### Run
```bash
./server 9900
```
#### Test
##### Create a book record: POST /books/
```bash
curl --location 'http://localhost:9900/books' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data '{
"name": "The Great Gatsby",
"author": "Fitzgerald"
}'
```
##### Get a book record by id
```bash
curl -XGET 'http://localhost:9900/books/12'
```
##### Get all books
```bash
curl --location 'http://localhost:9900/books'
```
##### Delete a book by id
```bash
curl --location --request DELETE 'http://localhost:9900/books/1804289383' \
--header 'Authorization: Basic YWRtaW46YWRtaW4='
```
##### Update a book by id
```bash
curl --location --request PUT 'http://localhost:9900/books/2074039068' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data '{
"name": "The Great Gatsby",
"author": "Fitzgerald G."
}'
```
#####