Skip to content

Commit

Permalink
Make middleware public (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored May 24, 2022
1 parent 5330d5d commit f07b4d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/VaporRouting/VaporRouting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ extension Application {
_ router: R,
use closure: @escaping (Request, R.Output) async throws -> AsyncResponseEncodable
) where R.Input == URLRequestData {
self.middleware.use(RoutingMiddleware(router: router, respond: closure))
self.middleware.use(AsyncRoutingMiddleware(router: router, respond: closure))
}
}

private struct RoutingMiddleware<Router: Parser>: AsyncMiddleware
/// Serves requests using a router and response handler.
///
/// You will not typically need to interact with this type directly. Instead you should use the
/// `mount` method on your Vapor application.
///
/// See ``VaporRouting`` for more information on usage.
public struct AsyncRoutingMiddleware<Router: Parser>: AsyncMiddleware
where Router.Input == URLRequestData {
let router: Router
let respond: (Request, Router.Output) async throws -> AsyncResponseEncodable
Expand Down

0 comments on commit f07b4d7

Please sign in to comment.