Skip to content

Commit 4656b94

Browse files
committed
Add http method metadata to endpoint
1 parent ed33b8f commit 4656b94

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Falco/Routing.fs

+12-1
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,21 @@ type internal FalcoEndpointDatasource(httpEndpoints : HttpEndpoint seq) =
134134
if strEmpty verbStr then endpoint.Pattern
135135
else strConcat [|verbStr; " "; endpoint.Pattern|]
136136

137-
let requestDelegate = HttpHandler.toRequestDelegate handler
137+
let httpMethodMetadata =
138+
match verb with
139+
| ANY -> HttpMethodMetadata [||]
140+
| _ -> HttpMethodMetadata [|verbStr|]
141+
142+
let routeNameMetadata = RouteNameMetadata(endpoint.Pattern)
143+
let metadataCollection = EndpointMetadataCollection(routeNameMetadata, httpMethodMetadata)
138144

145+
let requestDelegate = HttpHandler.toRequestDelegate handler
146+
139147
let endpointBuilder = RouteEndpointBuilder(requestDelegate, routePattern, order, DisplayName = displayName)
140148
endpointBuilder.DisplayName <- displayName
149+
150+
for metadata in metadataCollection do
151+
endpointBuilder.Metadata.Add(metadata)
141152

142153
for convention in conventions do
143154
convention.Invoke(endpointBuilder)

0 commit comments

Comments
 (0)