Skip to content

Commit 3a2c39d

Browse files
Merge pull request #17 from FireTail-io/create-middleware-once
Performance improvements
2 parents ff24787 + 5ff26c0 commit 3a2c39d

15 files changed

+301
-397
lines changed

.clang-format

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
---
2-
Language: Cpp
2+
Language: Cpp
33
# BasedOnStyle: Google
44
AccessModifierOffset: -1
55
AlignAfterOpenBracket: Align
66
AlignArrayOfStructures: None
77
AlignConsecutiveAssignments:
8-
Enabled: false
8+
Enabled: false
99
AcrossEmptyLines: false
10-
AcrossComments: false
11-
AlignCompound: false
12-
PadOperators: true
10+
AcrossComments: false
11+
AlignCompound: false
12+
PadOperators: true
1313
AlignConsecutiveBitFields:
14-
Enabled: false
14+
Enabled: false
1515
AcrossEmptyLines: false
16-
AcrossComments: false
17-
AlignCompound: false
18-
PadOperators: false
16+
AcrossComments: false
17+
AlignCompound: false
18+
PadOperators: false
1919
AlignConsecutiveDeclarations:
20-
Enabled: false
20+
Enabled: false
2121
AcrossEmptyLines: false
22-
AcrossComments: false
23-
AlignCompound: false
24-
PadOperators: false
22+
AcrossComments: false
23+
AlignCompound: false
24+
PadOperators: false
2525
AlignConsecutiveMacros:
26-
Enabled: false
26+
Enabled: false
2727
AcrossEmptyLines: false
28-
AcrossComments: false
29-
AlignCompound: false
30-
PadOperators: false
28+
AcrossComments: false
29+
AlignCompound: false
30+
PadOperators: false
3131
AlignEscapedNewlines: Left
32-
AlignOperands: Align
32+
AlignOperands: Align
3333
AlignTrailingComments:
34-
Kind: Always
35-
OverEmptyLines: 0
34+
Kind: Always
35+
OverEmptyLines: 0
3636
AllowAllArgumentsOnNextLine: true
3737
AllowAllParametersOfDeclarationOnNextLine: true
3838
AllowShortBlocksOnASingleLine: Never
@@ -52,27 +52,27 @@ BinPackArguments: true
5252
BinPackParameters: true
5353
BitFieldColonSpacing: Both
5454
BraceWrapping:
55-
AfterCaseLabel: false
56-
AfterClass: false
55+
AfterCaseLabel: false
56+
AfterClass: false
5757
AfterControlStatement: Never
58-
AfterEnum: false
58+
AfterEnum: false
5959
AfterExternBlock: false
60-
AfterFunction: false
61-
AfterNamespace: false
60+
AfterFunction: false
61+
AfterNamespace: false
6262
AfterObjCDeclaration: false
63-
AfterStruct: false
64-
AfterUnion: false
65-
BeforeCatch: false
66-
BeforeElse: false
63+
AfterStruct: false
64+
AfterUnion: false
65+
BeforeCatch: false
66+
BeforeElse: false
6767
BeforeLambdaBody: false
68-
BeforeWhile: false
69-
IndentBraces: false
68+
BeforeWhile: false
69+
IndentBraces: false
7070
SplitEmptyFunction: true
7171
SplitEmptyRecord: true
7272
SplitEmptyNamespace: true
7373
BreakAfterAttributes: Never
7474
BreakAfterJavaFieldAnnotations: false
75-
BreakArrays: true
75+
BreakArrays: true
7676
BreakBeforeBinaryOperators: None
7777
BreakBeforeConceptDeclarations: Always
7878
BreakBeforeBraces: Attach
@@ -81,14 +81,14 @@ BreakBeforeTernaryOperators: true
8181
BreakConstructorInitializers: BeforeColon
8282
BreakInheritanceList: BeforeColon
8383
BreakStringLiterals: true
84-
ColumnLimit: 80
85-
CommentPragmas: '^ IWYU pragma:'
84+
ColumnLimit: 120
85+
CommentPragmas: "^ IWYU pragma:"
8686
CompactNamespaces: false
8787
ConstructorInitializerIndentWidth: 4
8888
ContinuationIndentWidth: 4
8989
Cpp11BracedListStyle: true
9090
DerivePointerAlignment: true
91-
DisableFormat: false
91+
DisableFormat: false
9292
EmptyLineAfterAccessModifier: Never
9393
EmptyLineBeforeAccessModifier: LogicalBlock
9494
ExperimentalAutoDetectBinPacking: false
@@ -99,49 +99,49 @@ ForEachMacros:
9999
- BOOST_FOREACH
100100
IfMacros:
101101
- KJ_IF_MAYBE
102-
IncludeBlocks: Regroup
102+
IncludeBlocks: Regroup
103103
IncludeCategories:
104-
- Regex: '^<ext/.*\.h>'
105-
Priority: 2
106-
SortPriority: 0
107-
CaseSensitive: false
108-
- Regex: '^<.*\.h>'
109-
Priority: 1
110-
SortPriority: 0
111-
CaseSensitive: false
112-
- Regex: '^<.*'
113-
Priority: 2
114-
SortPriority: 0
115-
CaseSensitive: false
116-
- Regex: '.*'
117-
Priority: 3
118-
SortPriority: 0
119-
CaseSensitive: false
120-
IncludeIsMainRegex: '([-_](test|unittest))?$'
121-
IncludeIsMainSourceRegex: ''
104+
- Regex: '^<ext/.*\.h>'
105+
Priority: 2
106+
SortPriority: 0
107+
CaseSensitive: false
108+
- Regex: '^<.*\.h>'
109+
Priority: 1
110+
SortPriority: 0
111+
CaseSensitive: false
112+
- Regex: "^<.*"
113+
Priority: 2
114+
SortPriority: 0
115+
CaseSensitive: false
116+
- Regex: ".*"
117+
Priority: 3
118+
SortPriority: 0
119+
CaseSensitive: false
120+
IncludeIsMainRegex: "([-_](test|unittest))?$"
121+
IncludeIsMainSourceRegex: ""
122122
IndentAccessModifiers: false
123123
IndentCaseBlocks: false
124124
IndentCaseLabels: true
125125
IndentExternBlock: AfterExternBlock
126126
IndentGotoLabels: true
127127
IndentPPDirectives: None
128128
IndentRequiresClause: true
129-
IndentWidth: 2
129+
IndentWidth: 2
130130
IndentWrappedFunctionNames: false
131-
InsertBraces: false
131+
InsertBraces: false
132132
InsertNewlineAtEOF: false
133133
InsertTrailingCommas: None
134134
IntegerLiteralSeparator:
135-
Binary: 0
136-
Decimal: 0
137-
Hex: 0
135+
Binary: 0
136+
Decimal: 0
137+
Hex: 0
138138
JavaScriptQuotes: Leave
139139
JavaScriptWrapImports: true
140140
KeepEmptyLinesAtTheStartOfBlocks: false
141141
LambdaBodyIndentation: Signature
142-
LineEnding: DeriveLF
143-
MacroBlockBegin: ''
144-
MacroBlockEnd: ''
142+
LineEnding: DeriveLF
143+
MacroBlockBegin: ""
144+
MacroBlockEnd: ""
145145
MaxEmptyLinesToKeep: 1
146146
NamespaceIndentation: None
147147
ObjCBinPackProtocolList: Never
@@ -161,21 +161,21 @@ PenaltyExcessCharacter: 1000000
161161
PenaltyIndentedWhitespace: 0
162162
PenaltyReturnTypeOnItsOwnLine: 200
163163
PointerAlignment: Left
164-
PPIndentWidth: -1
164+
PPIndentWidth: -1
165165
QualifierAlignment: Leave
166166
RawStringFormats:
167-
- Language: Cpp
167+
- Language: Cpp
168168
Delimiters:
169169
- cc
170170
- CC
171171
- cpp
172172
- Cpp
173173
- CPP
174-
- 'c++'
175-
- 'C++'
176-
CanonicalDelimiter: ''
177-
BasedOnStyle: google
178-
- Language: TextProto
174+
- "c++"
175+
- "C++"
176+
CanonicalDelimiter: ""
177+
BasedOnStyle: google
178+
- Language: TextProto
179179
Delimiters:
180180
- pb
181181
- PB
@@ -192,16 +192,16 @@ RawStringFormats:
192192
- ParseTestProto
193193
- ParsePartialTestProto
194194
CanonicalDelimiter: pb
195-
BasedOnStyle: google
195+
BasedOnStyle: google
196196
ReferenceAlignment: Pointer
197-
ReflowComments: true
197+
ReflowComments: true
198198
RemoveBracesLLVM: false
199199
RemoveSemicolon: false
200200
RequiresClausePosition: OwnLine
201201
RequiresExpressionIndentation: OuterScope
202202
SeparateDefinitionBlocks: Leave
203203
ShortNamespaceLines: 1
204-
SortIncludes: Never
204+
SortIncludes: Never
205205
SortJavaStaticImport: Before
206206
SortUsingDeclarations: LexicographicNumeric
207207
SpaceAfterCStyleCast: false
@@ -219,7 +219,7 @@ SpaceBeforeParensOptions:
219219
AfterForeachMacros: true
220220
AfterFunctionDefinitionName: false
221221
AfterFunctionDeclarationName: false
222-
AfterIfMacros: true
222+
AfterIfMacros: true
223223
AfterOverloadedOperator: false
224224
AfterRequiresInClause: false
225225
AfterRequiresInExpression: false
@@ -229,28 +229,28 @@ SpaceBeforeSquareBrackets: false
229229
SpaceInEmptyBlock: false
230230
SpaceInEmptyParentheses: false
231231
SpacesBeforeTrailingComments: 2
232-
SpacesInAngles: Never
232+
SpacesInAngles: Never
233233
SpacesInConditionalStatement: false
234234
SpacesInContainerLiterals: true
235235
SpacesInCStyleCastParentheses: false
236236
SpacesInLineCommentPrefix:
237-
Minimum: 1
238-
Maximum: -1
237+
Minimum: 1
238+
Maximum: -1
239239
SpacesInParentheses: false
240240
SpacesInSquareBrackets: false
241-
Standard: Auto
241+
Standard: Auto
242242
StatementAttributeLikeMacros:
243243
- Q_EMIT
244244
StatementMacros:
245245
- Q_UNUSED
246246
- QT_REQUIRE_VERSION
247-
TabWidth: 8
248-
UseTab: Never
247+
TabWidth: 8
248+
UseTab: Never
249249
WhitespaceSensitiveMacros:
250250
- BOOST_PP_STRINGIZE
251251
- CF_SWIFT_NAME
252252
- NS_SWIFT_NAME
253253
- PP_STRINGIZE
254254
- STRINGIZE
255-
...
255+
---
256256

dev/appspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ paths:
1010
"200":
1111
description: An index.html file
1212
content:
13-
text/plain: {}
13+
text/html: {}
1414
/health:
1515
get:
1616
summary: Returns the status of the server

dev/nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ http {
1515
server {
1616
listen 80;
1717
server_name localhost;
18+
default_type application/json;
1819

1920
location / {
2021
root /usr/share/nginx/html/;

src/nginx_module/filter_context.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#include "firetail_module.h"
44

55
FiretailFilterContext *GetFiretailFilterContext(ngx_http_request_t *request) {
6-
FiretailFilterContext *ctx =
7-
ngx_http_get_module_ctx(request, ngx_firetail_module);
6+
FiretailFilterContext *ctx = ngx_http_get_module_ctx(request, ngx_firetail_module);
87
if (ctx == NULL) {
98
ctx = ngx_pcalloc(request->pool, sizeof(FiretailFilterContext));
109
if (ctx == NULL) {

src/nginx_module/filter_context.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ typedef struct {
1313
// request & response bodies & headers
1414
typedef struct {
1515
ngx_uint_t status_code;
16-
u_char *server;
1716
long request_body_size;
1817
long response_body_size;
18+
long request_headers_json_size;
1919
u_char *request_body;
2020
u_char *response_body;
21-
long request_header_count;
22-
long response_header_count;
21+
u_char *request_headers_json;
2322
HTTPHeader *request_headers;
24-
HTTPHeader *response_headers;
2523
ngx_uint_t done;
2624
ngx_uint_t bypass_response;
2725
u_char *request_result;
28-
HTTPHeader *recorded_request_header;
29-
long recorded_request_header_size;
3026
} FiretailFilterContext;
3127

3228
// This utility function will allow us to get the filter ctx whenever we need

0 commit comments

Comments
 (0)