forked from etr/libhttpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpserver.hpp
More file actions
139 lines (116 loc) · 2.97 KB
/
httpserver.hpp
File metadata and controls
139 lines (116 loc) · 2.97 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef _HTTPSERVER_HPP_
#define _HTTPSERVER_HPP_
#define _HTTPSERVER_HPP_INSIDE_
#ifdef SWIG
%include "std_string.i"
%include "std_vector.i"
%include "exception.i"
%include "stl.i"
%include "std_map.i"
%include "typemaps.i"
%include "cpointer.i"
%ignore policyCallback (void*, const struct sockaddr*, socklen_t);
%ignore error_log(void*, const char*, va_list);
%ignore access_log(webserver*, std::string);
%ignore uri_log(void*, const char*);
%ignore unescaper_func(void*, struct MHD_Connection*, char*);
%ignore internal_unescaper(void*, char*);
namespace std {
%template(StringVector) vector<std::string>;
%template(StringPair) pair<string, string>;
%template(ArgVector) vector<std::pair<std::string, std::string> >;
}
#ifdef SWIGPHP
%module(directors="1") libhttpserver_php
#endif
#ifdef SWIGJAVA
%javaconst(1);
%module(directors="1") libhttpserver_java
%include "jstring.i"
#endif
#ifdef SWIGRUBY
%module(directors="1") libhttpserver_ruby
#endif
#ifdef SWIGGUILE
%module(directors="1") libhttpserver_guile
#endif
#ifdef SWIGLUA
%module(directors="1") libhttpserver_lua
#endif
#ifdef SWIGPERL
%module(directors="1") libhttpserver_perl
#endif
#ifdef SWIGPYTHON
%module(directors="1") libhttpserver_python
#endif
%feature("director") http_resource;
#ifdef SWIGPYTHON
%typemap(out) string {
$result = PyString_FromStringAndSize($1,$1.size);
}
%feature("director:except") {
if ($error != NULL) {
throw Swig::DirectorMethodException();
}
}
#endif
%template(SQMHeaders) std::map<std::string, std::string>;
%extend std::map<std::string, std::string> {
std::string getHeader(std::string key) {
std::map<std::string,std::string >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
return "";
}
};
%exception {
try {
$action
}
#ifdef SWIGPYTHON //DirectorException should be ignored in python because is used as an internal trick
catch (const Swig::DirectorException& e)
{
PyEval_SaveThread();
PyErr_SetString(PyExc_RuntimeError, e.getMessage());
}
#endif
catch (const std::out_of_range& e) {
#ifdef SWIGPYTHON
PyEval_SaveThread();
#endif
SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what()));
} catch (const std::exception& e) {
#ifdef SWIGPYTHON
PyEval_SaveThread();
#endif
SWIG_exception(SWIG_RuntimeError, e.what());
} catch (...) {
#ifdef SWIGPYTHON
PyEval_SaveThread();
#endif
SWIG_exception(SWIG_RuntimeError, "Generic SWIG Exception");
}
};
%include "http_utils.hpp"
%include "http_request.hpp"
%include "http_response.hpp"
%include "http_resource.hpp"
%include "http_endpoint.hpp"
%include "webserver.hpp"
%{
#include "http_utils.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
#include "http_resource.hpp"
#include "http_endpoint.hpp"
#include "webserver.hpp"
%}
#endif
#include "httpserver/http_utils.hpp"
#include "httpserver/http_endpoint.hpp"
#include "httpserver/http_resource.hpp"
#include "httpserver/http_response.hpp"
#include "httpserver/http_request.hpp"
#include "httpserver/webserver.hpp"
#endif