added val_api_url and updated handle_api
This commit is contained in:
parent
ad249906f4
commit
bbb018471f
40
src/http.c
40
src/http.c
@ -326,10 +326,48 @@ out:
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int val_api_url(struct http_transaction *ta) {
|
||||||
|
char *req_path = bufio_offset2ptr(ta->client->bufio, ta->req_path);
|
||||||
|
if (!strcmp(req_path, "/api/login")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!strcmp(req_path, "/api/video")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
static bool
|
static bool
|
||||||
handle_api(struct http_transaction *ta)
|
handle_api(struct http_transaction *ta)
|
||||||
{
|
{
|
||||||
return send_error(ta, HTTP_NOT_FOUND, "API not implemented");
|
int val = val_api_url(ta);
|
||||||
|
|
||||||
|
if (val == -1){
|
||||||
|
return send_not_found(ta);
|
||||||
|
}
|
||||||
|
|
||||||
|
http_add_header(&ta->resp_headers, "Accept-Ranges", "bytes");
|
||||||
|
if (val == 0) {
|
||||||
|
if (ta->req_method == HTTP_POST) {
|
||||||
|
// Handle login post
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ta->req_method == HTTP_GET){
|
||||||
|
// Handle login get
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
return send_error(ta, HTTP_METHOD_NOT_ALLOWED, "Unknown method.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Handle video api
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up an http client, associating it with a bufio buffer. */
|
/* Set up an http client, associating it with a bufio buffer. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user