Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ func buildRouter() -> Router<AppRequestContext> {
// logging middleware
LogRequestsMiddleware(.info)
}
// Add health endpoint
router.get("/health") { _, _ -> HTTPResponse.Status in
return .ok
// Add default endpoint
router.get("/") { _,_ in
return "Hello!"
}
router.addRoutes(TodoController().endpoints, atPath: "/todos")
return router
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ func buildRouter() -> Router<AppRequestContext> {
// logging middleware
LogRequestsMiddleware(.info)
}
// Add health endpoint
router.get("/health") { _, _ -> HTTPResponse.Status in
return .ok
// Add default endpoint
router.get("/") { _,_ in
return "Hello!"
}
return router
}
}
4 changes: 2 additions & 2 deletions Hummingbird.docc/Tutorials/Todos/Todos-1-Template.tutorial
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Step {
If we look further down the file we can find the `buildRouter()` function.

Here we create the `Router`. We add a logging middleware to it (this logs all requests to the router). The function uses a result builder to create a stack of middleware, but you can also use `Router.add(middleware:)` to add individual middleware. Finally we add a single endpoint GET `/health` which returns a 200 (Ok) response.
Here we create the `Router`. We add a logging middleware to it (this logs all requests to the router). The function uses a result builder to create a stack of middleware, but you can also use `Router.add(middleware:)` to add individual middleware. Finally we add a single endpoint GET `/` which returns a String response: "Hello".
@Code(name: "buildRouter() - Sources/App/Application+build.swift", file: todos-template-06.swift)
}
@Step {
Expand All @@ -53,4 +53,4 @@
}
}
}
}
}