Skip to content

Commit 493d82c

Browse files
authored
feat: PUT instead of POST for editing tickets (#39)
* feat: PUT instead of POST for editing tickets * docs: correct paths
1 parent 6917528 commit 493d82c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Cargo.lock
1515

1616
# IDE
1717
.idea/
18+
.vscode/
1819

1920
# Database
2021
cira-backend.sqlite

readme.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cargo test
6767
#### Create a new ticket
6868

6969
```http
70-
POST /tickets
70+
POST /api/tickets
7171
```
7272

7373
Your payload must be valid JSON and contain the following properties:
@@ -98,15 +98,15 @@ Creates a new ticket and returns it.
9898
#### Get tickets
9999

100100
```http
101-
GET /tickets
101+
GET /api/tickets
102102
```
103103

104104
Get all tickets.
105105

106106
#### Delete ticket
107107

108108
```http
109-
DELETE /tickets/{id}
109+
DELETE /api/tickets/{id}
110110
```
111111

112112
URL parameters:
@@ -120,7 +120,7 @@ Deletes a ticket and returns it.
120120
#### Edit a ticket
121121

122122
```http
123-
POST /tickets/{id}
123+
PUT /api/tickets/{id}
124124
```
125125

126126
URL parameters:
@@ -157,7 +157,7 @@ Updates a ticket and returns it.
157157
#### Sign up
158158

159159
```
160-
POST /users
160+
POST /api/signup
161161
```
162162

163163
Your payload must be valid JSON and contain the following properties:
@@ -173,7 +173,7 @@ Create a new user and return it.
173173
#### Filter tickets
174174

175175
```http
176-
POST /filter
176+
POST /api/filter
177177
```
178178

179179
Your payload must be valid JSON and contain the following properties:

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use actix_cors::Cors;
2525
use actix_web::cookie::time::Duration;
2626
use actix_web::cookie::Cookie;
2727
use actix_web::web::{Json, Path};
28-
use actix_web::{delete, get, post, web, App, HttpResponse, HttpServer, Responder};
28+
use actix_web::{delete, get, post, put, web, App, HttpResponse, HttpServer, Responder};
2929
use actix_web_httpauth::extractors::bearer::BearerAuth;
3030
use actix_web_httpauth::middleware::HttpAuthentication;
3131
use argonautica::Verifier;
@@ -118,7 +118,7 @@ async fn filter_tickets(payload: Json<FilterPayload>) -> impl Responder {
118118
}
119119
}
120120

121-
#[post("/tickets/{id}")]
121+
#[put("/tickets/{id}")]
122122
async fn edit(payload: Json<TicketPayload>, ticket_id: Path<i32>) -> impl Responder {
123123
let ticket_id: i32 = ticket_id.into_inner();
124124

@@ -411,7 +411,7 @@ mod tests {
411411
"labels": []
412412
});
413413

414-
let req = TestRequest::post()
414+
let req = TestRequest::put()
415415
.uri("/tickets/-1")
416416
.set_json(payload)
417417
.to_request();
@@ -457,7 +457,7 @@ mod tests {
457457
});
458458

459459
let app = test::init_service(App::new().service(edit)).await;
460-
let req = TestRequest::post()
460+
let req = TestRequest::put()
461461
.uri("/tickets/1")
462462
.set_json(payload)
463463
.to_request();

0 commit comments

Comments
 (0)