Initial commit.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import Hummingbird
|
||||
|
||||
/// A type exposing its endpoints as a route collection ready to be added to a router.
|
||||
///
|
||||
/// Conforming controllers group related endpoints behind a single ``routes`` property, so the application composes them declaratively with
|
||||
/// ``Hummingbird/RouterMethods/addController(_:)``:
|
||||
///
|
||||
/// ```swift
|
||||
/// struct HealthController<Context: RequestContext>: RouterController {
|
||||
/// var routes: RouteCollection<Context> {
|
||||
/// RouteCollection(context: Context.self)
|
||||
/// .get("health") { _, _ in HTTPResponse.Status.ok }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// router.addController {
|
||||
/// HealthController<AppRequestContext>()
|
||||
/// }
|
||||
/// ```
|
||||
public protocol RouterController<Context>: Sendable {
|
||||
|
||||
// MARK: Associated types
|
||||
|
||||
/// The request context the controller's routes operate on.
|
||||
associatedtype Context: RequestContext
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The collection of routes the controller exposes.
|
||||
var routes: RouteCollection<Context> { get }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user