Slon/Api/{V1,V2}/Media: Implement PUT /api/v1/media, POST /api/v2/media
This commit is contained in:
parent
95aecb9fb1
commit
b104551bbd
9 changed files with 284 additions and 3 deletions
21
Slon/Api/V1/Media.HC
Normal file
21
Slon/Api/V1/Media.HC
Normal file
|
@ -0,0 +1,21 @@
|
|||
U0 @slon_api_v1_media_put(SlonHttpSession* session)
|
||||
{
|
||||
SLON_SCRATCH_BUFFER_AND_REQUEST_JSON
|
||||
no_warn scratch_buffer;
|
||||
|
||||
if (@slon_api_authorized(session)) {
|
||||
if (session->path_count() < 4) {
|
||||
session->status(400);
|
||||
return;
|
||||
}
|
||||
U8* id = session->path(3);
|
||||
if (db->o("media")->@(id)) {
|
||||
db->o("media")->o(id)->set("description", request_json->@("description"), JSON_STRING);
|
||||
session->send(db->o("media")->o(id));
|
||||
} else {
|
||||
session->status(404);
|
||||
}
|
||||
} else {
|
||||
session->status(401);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue