| 6 | var plugin = new RASP('test'); |
| 7 | |
| 8 | function checkContext(context) { |
| 9 | function assert(flag) { |
| 10 | if (!flag) { |
| 11 | throw new Error(); |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | assert(context.method); |
| 16 | assert(context.protocol === 'http/1.1'); |
| 17 | assert(context.server); |
| 18 | assert(context.url); |
| 19 | assert(context.path); |
| 20 | assert(context.parameter.test[0] === 'a' && context.parameter.test[1] === 'b'); |
| 21 | assert(context.header['test-test'] === 'Test-Test'); |
| 22 | assert(context.querystring); |
| 23 | assert(context.remoteAddr); |
| 24 | } |
| 25 | |
| 26 | plugin.register('request', function (params, context) { |
| 27 | if (/request/.test(context.path)) { |