Statistics
| Branch: | Revision:

peerstreamer-src / src / path_handlers.h @ 58fb2cdc

History | View | Annotate | Download (2.08 KB)

1 9eb656e7 Luca Baldesi
/*******************************************************************
2
* PeerStreamer-ng is a P2P video streaming application exposing a ReST
3
* interface.
4
* Copyright (C) 2015 Luca Baldesi <luca.baldesi@unitn.it>
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Affero General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU Affero General Public License for more details.
15
*
16
* You should have received a copy of the GNU Affero General Public License
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
*******************************************************************/
19
20 c039490c Luca Baldesi
#ifndef __PATH_HANDLERS__ 
21
#define __PATH_HANDLERS__ 
22
23 9eb656e7 Luca Baldesi
#include <stdint.h>
24
25
#include<router.h>
26 07072cd2 Luca Baldesi
#include<pschannel.h>
27
28
29 c039490c Luca Baldesi
char * mg_uri_field(struct http_message *hm, uint8_t pos);
30 07072cd2 Luca Baldesi
31 c039490c Luca Baldesi
void channel_index(struct mg_connection *nc, struct http_message *hm);
32
void streamer_create(struct mg_connection *nc, struct http_message *hm);
33 4d6f8fd5 Luca Baldesi
void streamer_update(struct mg_connection *nc, struct http_message *hm);
34
35 3af4c8d7 Luca Baldesi
void source_index(struct mg_connection *nc, struct http_message *hm);
36
void source_streamer_create(struct mg_connection *nc, struct http_message *hm);
37
void source_streamer_update(struct mg_connection *nc, struct http_message *hm);
38
39 9eb656e7 Luca Baldesi
uint8_t load_path_handlers(struct router *r)
40
{
41
        uint8_t res = 0;
42
43 59457bd3 Luca Baldesi
        res |= router_add_route(r, "GET", "^/channels$", channel_index);
44
        res |= router_add_route(r, "POST", "^/channels/[a-zA-Z0-9]+$", streamer_create);
45 4d6f8fd5 Luca Baldesi
        res |= router_add_route(r, "UPDATE", "^/channels/[a-zA-Z0-9]+$", streamer_update);
46 07072cd2 Luca Baldesi
47 3af4c8d7 Luca Baldesi
        res |= router_add_route(r, "GET", "^/sources$", source_index);
48
        res |= router_add_route(r, "POST", "^/sources/[a-zA-Z0-9]+$", source_streamer_create);
49
        res |= router_add_route(r, "UPDATE", "^/sources/[a-zA-Z0-9]+$", source_streamer_update);
50
51 9eb656e7 Luca Baldesi
        return res;
52
}
53 c039490c Luca Baldesi
54
#endif