mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-26 05:04:14 +00:00
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1425 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
3230f6ef20
commit
295424544d
6 files changed
+129
-11
No files matched your search
@@ -39,15 +39,33 @@ static const char modname[] = "mod_event_test";
|
||||
static void event_handler(switch_event_t *event)
|
||||
{
|
||||
char buf[1024];
|
||||
switch_xml_t xml;
|
||||
char *xmlstr = "N/A";
|
||||
uint8_t dofree = 0;
|
||||
|
||||
switch (event->event_id) {
|
||||
case SWITCH_EVENT_LOG:
|
||||
return;
|
||||
default:
|
||||
switch_event_serialize(event, buf, sizeof(buf), NULL);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT\n--------------------------------\n%s\n", buf);
|
||||
if ((xml = switch_event_xmlize(event, NULL))) {
|
||||
xmlstr = switch_xml_toxml(xml);
|
||||
dofree++;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (text version)\n--------------------------------\n%s", buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (dofree) {
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
if (xmlstr) {
|
||||
free(xmlstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -208,10 +208,23 @@ abyss_bool HandleHook(TSession *r)
|
||||
char *m = "text/html";
|
||||
switch_stream_handle_t stream = {0};
|
||||
char *command;
|
||||
|
||||
if(strncmp(r->uri, "/api/", 5)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (switch_event_create(&stream.event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
|
||||
if (r->uri) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->uri);
|
||||
if (r->query) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-QUERY", r->query);
|
||||
if (r->host) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-HOST", r->host);
|
||||
if (r->from) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-FROM", r->from);
|
||||
if (r->useragent) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-USER-AGENT", r->useragent);
|
||||
if (r->referer) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-REFERER", r->referer);
|
||||
if (r->requestline) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-REQUESTLINE", r->requestline);
|
||||
if (r->user) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-USER", r->user);
|
||||
if (r->port) switch_event_add_header(stream.event, SWITCH_STACK_BOTTOM, "HTTP-PORT", "%u", r->port);
|
||||
}
|
||||
|
||||
command = r->uri + 5;
|
||||
|
||||
ResponseChunked(r);
|
||||
|
||||
Reference in new issue
Block a user