72 lines
2.2 KiB
ReStructuredText
72 lines
2.2 KiB
ReStructuredText
### Get all heroes (no auth)
|
|
GET http://localhost:8080/api/v1/heroes
|
|
Accept: application/json
|
|
|
|
### Get active heroes (no auth)
|
|
GET http://localhost:8080/api/v1/hero
|
|
Accept: application/json
|
|
|
|
### Update hero (JSON) — requires admin token
|
|
PUT http://localhost:8080/api/v1/hero/1
|
|
Content-Type: application/json
|
|
Authorization: Bearer {{ADMIN_TOKEN}}
|
|
|
|
{
|
|
"title": "updated-via-rest",
|
|
"is_active": false
|
|
}
|
|
|
|
### Update hero (multipart/form-data) — send file + is_active=false
|
|
PUT http://localhost:8080/api/v1/hero/1
|
|
Authorization: Bearer {{ADMIN_TOKEN}}
|
|
Content-Type: multipart/form-data; boundary=---011000010111000001101001
|
|
|
|
Content-Disposition: form-data; name="title"
|
|
|
|
multipart-update
|
|
Content-Disposition: form-data; name="is_active"
|
|
|
|
false
|
|
Content-Disposition: form-data; name="image"; filename="test.jpg"
|
|
Content-Type: image/jpeg
|
|
|
|
< ./path/to/test.jpg
|
|
|
|
### Delete hero (admin)
|
|
DELETE http://localhost:8080/api/v1/hero/1
|
|
Authorization: Bearer {{ADMIN_TOKEN}}
|
|
|
|
# Equivalent curl examples:
|
|
#
|
|
# curl GET all heroes
|
|
# curl -sS http://localhost:8080/api/v1/heroes | jq '.'
|
|
#
|
|
# curl update JSON
|
|
# curl -X PUT "http://localhost:8080/api/v1/hero/1" -H "Authorization: Bearer <ADMIN_TOKEN>" -H "Content-Type: application/json" -d '{"title":"test","is_active":false}'
|
|
#
|
|
# curl multipart (with image)
|
|
# curl -X PUT "http://localhost:8080/api/v1/hero/1" -H "Authorization: Bearer <ADMIN_TOKEN>" -F "title=multipart-test" -F "is_active=false" -F "image=@/absolute/path/to/image.jpg"
|
|
|
|
### Update user (multipart/form-data) — upload avatar + fields (admin)
|
|
PUT http://localhost:8080/api/v1/users/2
|
|
Authorization: Bearer {{ADMIN_TOKEN}}
|
|
Content-Type: multipart/form-data; boundary=---011000010111000001101001
|
|
|
|
-----011000010111000001101001
|
|
Content-Disposition: form-data; name="first_name"
|
|
|
|
Ayse
|
|
-----011000010111000001101001
|
|
Content-Disposition: form-data; name="email_verified"
|
|
|
|
false
|
|
-----011000010111000001101001
|
|
Content-Disposition: form-data; name="avatar"; filename="avatar.jpg"
|
|
Content-Type: image/jpeg
|
|
|
|
< ./path/to/avatar.jpg
|
|
-----011000010111000001101001--
|
|
|
|
# curl equivalent:
|
|
# curl -X PUT "http://localhost:8080/api/v1/users/2" -H "Authorization: Bearer <ADMIN_TOKEN>" -F "first_name=Ayse" -F "email_verified=false" -F "avatar=@/absolute/path/to/avatar.jpg"
|