1
1
using GenHTTP . Api . Content ;
2
2
using GenHTTP . Api . Infrastructure ;
3
3
using GenHTTP . Api . Protocol ;
4
+
4
5
using GenHTTP . Modules . Conversion ;
5
6
using GenHTTP . Modules . Conversion . Formatters ;
6
7
using GenHTTP . Modules . Conversion . Serializers ;
@@ -11,7 +12,7 @@ namespace GenHTTP.Modules.Functional.Provider;
11
12
12
13
public class InlineBuilder : IHandlerBuilder < InlineBuilder >
13
14
{
14
- private static readonly HashSet < FlexibleRequestMethod > AllMethods = [ ..Enum . GetValues < RequestMethod > ( ) . Select ( m => FlexibleRequestMethod . Get ( m ) ) ] ;
15
+ private static readonly HashSet < FlexibleRequestMethod > AllMethods = [ ..Enum . GetValues < RequestMethod > ( ) . Select ( FlexibleRequestMethod . Get ) ] ;
15
16
16
17
private readonly List < IConcernBuilder > _Concerns = [ ] ;
17
18
@@ -73,92 +74,62 @@ public InlineBuilder Formatters(IBuilder<FormatterRegistry> registry)
73
74
/// Adds a route for a GET request to the root of the handler.
74
75
/// </summary>
75
76
/// <param name="function">The logic to be executed</param>
76
- public InlineBuilder Get ( Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
77
- {
78
- FlexibleRequestMethod . Get ( RequestMethod . Get )
79
- } ) ;
77
+ public InlineBuilder Get ( Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Get ) ] ) ;
80
78
81
79
/// <summary>
82
80
/// Adds a route for a GET request to the specified path.
83
81
/// </summary>
84
82
/// <param name="path">The path of the request to handle (e.g. "/my-method")</param>
85
83
/// <param name="function">The logic to be executed</param>
86
- public InlineBuilder Get ( string path , Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
87
- {
88
- FlexibleRequestMethod . Get ( RequestMethod . Get )
89
- } , path ) ;
84
+ public InlineBuilder Get ( string path , Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Get ) ] , path ) ;
90
85
91
86
/// <summary>
92
87
/// Adds a route for a HEAD request to the root of the handler.
93
88
/// </summary>
94
89
/// <param name="function">The logic to be executed</param>
95
- public InlineBuilder Head ( Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
96
- {
97
- FlexibleRequestMethod . Get ( RequestMethod . Head )
98
- } ) ;
90
+ public InlineBuilder Head ( Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Head ) ] ) ;
99
91
100
92
/// <summary>
101
93
/// Adds a route for a HEAD request to the specified path.
102
94
/// </summary>
103
95
/// <param name="path">The path of the request to handle (e.g. "/my-method")</param>
104
- public InlineBuilder Head ( string path , Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
105
- {
106
- FlexibleRequestMethod . Get ( RequestMethod . Head )
107
- } , path ) ;
96
+ public InlineBuilder Head ( string path , Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Head ) ] , path ) ;
108
97
109
98
/// <summary>
110
99
/// Adds a route for a POST request to the root of the handler.
111
100
/// </summary>
112
101
/// <param name="function">The logic to be executed</param>
113
- public InlineBuilder Post ( Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
114
- {
115
- FlexibleRequestMethod . Get ( RequestMethod . Post )
116
- } ) ;
102
+ public InlineBuilder Post ( Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Post ) ] ) ;
117
103
118
104
/// <summary>
119
105
/// Adds a route for a POST request to the specified path.
120
106
/// </summary>
121
107
/// <param name="path">The path of the request to handle (e.g. "/my-method")</param>
122
- public InlineBuilder Post ( string path , Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
123
- {
124
- FlexibleRequestMethod . Get ( RequestMethod . Post )
125
- } , path ) ;
108
+ public InlineBuilder Post ( string path , Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Post ) ] , path ) ;
126
109
127
110
/// <summary>
128
111
/// Adds a route for a PUT request to the root of the handler.
129
112
/// </summary>
130
113
/// <param name="function">The logic to be executed</param>
131
- public InlineBuilder Put ( Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
132
- {
133
- FlexibleRequestMethod . Get ( RequestMethod . Put )
134
- } ) ;
114
+ public InlineBuilder Put ( Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Put ) ] ) ;
135
115
136
116
/// <summary>
137
117
/// Adds a route for a PUT request to the specified path.
138
118
/// </summary>
139
119
/// <param name="path">The path of the request to handle (e.g. "/my-method")</param>
140
- public InlineBuilder Put ( string path , Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
141
- {
142
- FlexibleRequestMethod . Get ( RequestMethod . Put )
143
- } , path ) ;
120
+ public InlineBuilder Put ( string path , Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Put ) ] , path ) ;
144
121
145
122
/// <summary>
146
123
/// Adds a route for a DELETE request to the root of the handler.
147
124
/// </summary>
148
125
/// <param name="function">The logic to be executed</param>
149
- public InlineBuilder Delete ( Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
150
- {
151
- FlexibleRequestMethod . Get ( RequestMethod . Delete )
152
- } ) ;
126
+ public InlineBuilder Delete ( Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Delete ) ] ) ;
153
127
154
128
/// <summary>
155
129
/// Adds a route for a DELETE request to the specified path.
156
130
/// </summary>
157
131
/// <param name="path">The path of the request to handle (e.g. "/my-method")</param>
158
- public InlineBuilder Delete ( string path , Delegate function ) => On ( function , new HashSet < FlexibleRequestMethod >
159
- {
160
- FlexibleRequestMethod . Get ( RequestMethod . Delete )
161
- } , path ) ;
132
+ public InlineBuilder Delete ( string path , Delegate function ) => On ( function , [ FlexibleRequestMethod . Get ( RequestMethod . Delete ) ] , path ) ;
162
133
163
134
/// <summary>
164
135
/// Executes the given function for the specified path and method.
0 commit comments