-
Notifications
You must be signed in to change notification settings - Fork 250
/
url.h
59 lines (46 loc) · 1.89 KB
/
url.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Onion HTTP server library
Copyright (C) 2010-2016 David Moreno Montero and others
This library is free software; you can redistribute it and/or
modify it under the terms of, at your choice:
a. the Apache License Version 2.0.
b. the GNU General Public License as published by the
Free Software Foundation; either version 2.0 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of both libraries, if not see
<http://www.gnu.org/licenses/> and
<http://www.apache.org/licenses/LICENSE-2.0>.
*/
#ifndef ONION_URL_H
#define ONION_URL_H
#include "types.h"
#ifdef __cplusplus
extern "C"{
#endif
/// @defgroup url URL handlers
/// @{
/// Creates an handler that checks that crrent path matches the current regexp, and passes to next.
onion_url *onion_url_new();
/// Frees the url data
void onion_url_free(onion_url *url);
/// Adds a simple handler, with no custom data
int onion_url_add(onion_url *url, const char *regexp, void *handler_f);
/// Adds a handler, with custom data
int onion_url_add_with_data(onion_url *url, const char *regexp, void *handler_f, void *data, void *datafree);
/// Adds a handler, using handler methods
int onion_url_add_handler(onion_url *url, const char *regexp, onion_handler *handler);
/// Addsa another url on this regexp
int onion_url_add_url(onion_url *url, const char *regexp, onion_url *handler);
/// Adds a simple handler, it has static data and a default return code
int onion_url_add_static(onion_url *url, const char *regexp, const char *text, int http_code);
/// Returns the related handler for this url
onion_handler *onion_url_to_handler(onion_url *url);
/// @}
#ifdef __cplusplus
}
#endif
#endif