-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
80 lines (47 loc) · 1.68 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Dancer2 REST API
----------------
INSTALL:
$ sudo cpanm -v Dancer2::Plugin::DBIC
$ sudo cpanm -v Dancer2::Serializer::JSON
$ sudo apt install sqlite3
$ sqlite3 bookstore.db < bookstore.sql
$ SCHEMA_LOADER_BACKCOMPAT=1 perl populate_database.pl
TESTING:
$ perl Makefile.PL
$ make
$ make test
RUN:
- sudo plackup bin/app.psgi
ROUTES:
- List authors
$ curl -X GET http://localhost:5000/api/authors
- List all books of the given author
$ curl -X GET http://localhost:5000/api/authors/1/books
- Fetch author details
$ curl -X GET http://localhost:5000/api/authors/1
- Add new author
$ curl -X POST http://localhost:5000/api/authors
-d '{ "first_name":"X", "last_name":"Y", "country":"Z" }'
- Update author details
$ curl -X PUT http://localhost:5000/api/authors/4
-d '{ "first_name":"X1", "last_name":"Y1", "country":"Z1" }'
- Patch author details
$ curl -X PATCH http://localhost:5000/api/authors/4
-d '{ "first_name":"X2" }'
- Delete author
$ curl -X DELETE http://localhost:5000/api/authors/4
- List books
$ curl -X GET http://localhost:5000/api/books
- Fetch book details
$ curl -X GET http://localhost:5000/api/books/1
- Add new book
$ curl -X POST http://localhost:5000/api/books
-d '{ "author":"3", "title":"T", "isbn":"ISBN", "pub_date":"2010-07-01" }'
- Update book details
$ curl -X PUT http://localhost:5000/api/books/7
-d '{ "author":"3", "title":"T1", "isbn":"ISBN-1", "pub_date":"2010-07-01" }'
- Patch book details
$ curl -X PATCH http://localhost:5000/api/books/7
-d '{ "title":"T2" }'
- Delete book
$ curl -X DELETE http://localhost:5000/api/books/7