File tree Expand file tree Collapse file tree 3 files changed +61
-1
lines changed
src/BenchmarksApps/MapAction Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -38,11 +38,16 @@ parameters:
38
38
arguments : --scenario mapaction $(plaintextJobs) --property scenario=PlaintextMapAction --property protocol=http
39
39
- displayName : Plaintext Endpoint
40
40
arguments : --scenario endpoint $(plaintextJobs) --property scenario=PlaintextEndpoint --property protocol=http
41
+ - displayName : Plaintext (No Filters)
42
+ arguments : --scenario plainTextSansFilter $(plaintextJobs) --property scenario=PlaintextWithParameterNoFilter --property protocol=http
43
+ - displayName : Plaintext (Empty Filters)
44
+ arguments : --scenario plainTextEmptyFilter $(plaintextJobs) --property scenario=PlaintextWithParameterEmptyFilter --property protocol=http
45
+ - displayName : Plaintext (With Filters)
46
+ arguments : --scenario plainTextWithFilter $(plaintextJobs) --property scenario=PlaintextWithParametertWithFilter --property protocol=http
41
47
- displayName : Plaintext Connection Close
42
48
arguments : --scenario connectionclose $(plaintextJobs) --property scenario=ConnectionClose --property protocol=http --variable connections=32 --property connections=32
43
49
- displayName : Plaintext Connection Close Https
44
50
arguments : --scenario connectionclosehttps $(plaintextJobs) --property scenario=ConnectionCloseHttps --property protocol=https --variable connections=32 --property connections=32
45
- - displayName : Plaintext Connection Close Https HttpSys
46
51
arguments : --scenario connectionclosehttps $(plaintextJobs) --property scenario=ConnectionCloseHttpsHttpSys --property protocol=https --variable connections=32 --property connections=32 --variable server=HttpSys --application.options.requiredOperatingSystem windows
47
52
48
53
# Json
Original file line number Diff line number Diff line change @@ -92,6 +92,36 @@ scenarios:
92
92
presetHeaders : plaintext
93
93
path : /plaintext
94
94
pipeline : 16
95
+
96
+ plainTextSansFilter :
97
+ application :
98
+ job : mapaction
99
+ load :
100
+ job : wrk
101
+ variables :
102
+ presetHeaders : plaintext
103
+ path : /hello/TesterName
104
+ pipeline : 16
105
+
106
+ plainTextEmptyFilter :
107
+ application :
108
+ job : mapaction
109
+ load :
110
+ job : wrk
111
+ variables :
112
+ presetHeaders : plaintext
113
+ path : /helloEmptyFilter/TesterName
114
+ pipeline : 16
115
+
116
+ plainTextWithFilter :
117
+ application :
118
+ job : mapaction
119
+ load :
120
+ job : wrk
121
+ variables :
122
+ presetHeaders : plaintext
123
+ path : /helloFiltered/TesterName
124
+ pipeline : 16
95
125
96
126
connectionclose :
97
127
application :
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Reflection ;
2
3
using Microsoft . AspNetCore . Builder ;
3
4
using Microsoft . AspNetCore . Hosting ;
5
+ using Microsoft . AspNetCore . Http ;
4
6
using Microsoft . AspNetCore . Mvc ;
5
7
using Microsoft . Extensions . Hosting ;
6
8
using Microsoft . Extensions . Logging ;
23
25
24
26
object Json ( ) => new { message = "Hello, World!" } ;
25
27
endpoints . MapGet ( "/json" , ( Func < object > ) Json ) ;
28
+
29
+ // Parameterized plain-text endpoint
30
+ string SayHello ( string name ) => $ "Hello, { name } !";
31
+ // With no filters
32
+ endpoints . MapGet ( "/hello/{name}" , SayHello ) ;
33
+ // With a filter that no-ops
34
+ endpoints . MapGet ( "/helloEmptyFilter/{name}" , SayHello )
35
+ . AddFilter ( ( context , next ) => next ( context ) ) ;
36
+ endpoints
37
+ . MapGet ( "/helloFiltered/{name}" , SayHello )
38
+ . AddFilter ( ( routeHandlerContext , next ) => {
39
+ var hasSingleParam = routeHandlerContext . MethodInfo . GetParameters ( ) . Length == 1 ;
40
+ var isStringParam = routeHandlerContext . MethodInfo . GetParameters ( ) [ 0 ] . ParameterType == typeof ( string ) ;
41
+
42
+ return ( context ) =>
43
+ {
44
+ if ( hasSingleParam && isStringParam )
45
+ {
46
+ context . Parameters [ 0 ] = context . Parameters [ 0 ] . ToUpperInvariant ( ) ;
47
+ }
48
+ return next ( context ) ;
49
+ } ;
50
+ } ) ;
26
51
} ) ;
27
52
28
53
} ) ;
You can’t perform that action at this time.
0 commit comments