forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeRequestInfoCollector.ts
More file actions
29 lines (26 loc) · 942 Bytes
/
NodeRequestInfoCollector.ts
File metadata and controls
29 lines (26 loc) · 942 Bytes
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
import { IRequestInfo } from '../models/IRequestInfo';
import { IRequestInfoCollector } from 'IRequestInfoCollector';
import { EventPluginContext } from '../plugins/EventPluginContext';
import { Utils } from '../Utils';
export class NodeRequestInfoCollector implements IRequestInfoCollector {
getRequestInfo(context:EventPluginContext):IRequestInfo {
if (!context.contextData['@request']) {
return null;
}
var request = context.contextData['@request'];
var ri:IRequestInfo = {
client_ip_address: request.ip,
user_agent: request.headers['user-agent'],
is_secure: request.secure,
http_method: request.method,
host: request.hostname || request.host,
//port: TODO,
path: request.path,
post_data: request.body,
//referrer: TODO,
cookies: Utils.getCookies((request || {}).headers['cookie'], '; '),
query_string: request.params
};
return ri;
}
}