Skip to content

Commit 1f5f12c

Browse files
authored
Update README.md
added curl scripts to test endpoints;
1 parent 446fdb4 commit 1f5f12c

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,77 @@ My endeavour to learn Rust started a couple of weeks ago and it's been quite int
55
This project is the first one I created following the book "Rust web development" [https://www.manning.com/books/rust-web-development]. Intersting book that let you build from start to finish a small api, BUT, at the end the project does not fully work as expected.
66

77
Here, you can see some differences from the original project that I need to add to make it work as expected. Hope that it can help someone else!
8+
9+
## Test the endpoints
10+
11+
You can use the following curl scripts to test. Don't forget to rename the "<auth-token>" and pay atention on the ids!
12+
13+
### get questions
14+
```
15+
curl --location 'localhost:8080/questions'
16+
```
17+
18+
### post a question
19+
```
20+
curl --location 'localhost:8080/questions' \
21+
--header 'Content-Type: application/json' \
22+
--header 'Authorization: <auth-token>' \
23+
--data '{
24+
"id": "2",
25+
"title": "New question",
26+
"content": "brexit was a shitty idea!",
27+
"tags": [
28+
"general"
29+
]
30+
}'
31+
```
32+
33+
### update question
34+
```
35+
curl --location --request PUT 'localhost:8080/questions/1' \
36+
--header 'Content-Type: application/json' \
37+
--header 'Authorization: <auth-token>' \
38+
--data '{
39+
"id": 1,
40+
"title": "bleble",
41+
"content": "OLD CONTENT",
42+
"tags": [
43+
"general"
44+
]
45+
}'
46+
```
47+
48+
### delete question
49+
```
50+
curl --location --request DELETE 'localhost:8080/questions/1' \
51+
--header 'Authorization: <auth-token>'
52+
```
53+
54+
### post answer
55+
```
56+
curl --location 'localhost:8080/answers' \
57+
--header 'Content-Type: application/x-www-form-urlencoded' \
58+
--header 'Authorization: <auth-token>' \
59+
--data-urlencode 'content=blabla' \
60+
--data-urlencode 'question_id=1'
61+
```
62+
63+
### user registration
64+
```
65+
curl --location 'localhost:8080/registration' \
66+
--header 'Content-Type: application/json' \
67+
--data-raw '{
68+
"email": "[email protected]",
69+
"password": "somepass"
70+
}'
71+
```
72+
73+
### user login
74+
```
75+
curl --location 'localhost:8080/login' \
76+
--header 'Content-Type: application/json' \
77+
--data-raw '{
78+
"email": "[email protected]",
79+
"password": "somepass"
80+
}'
81+
```

0 commit comments

Comments
 (0)