Skip to content

Commit

Permalink
Hello route (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Sep 20, 2024
1 parent e9a5655 commit c995119
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Sources/App/Application+build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,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 Tests/AppTests/AppTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ final class AppTests: XCTestCase {
let args = TestArguments()
let app = try await buildApplication(args)
try await app.test(.router) { client in
try await client.execute(uri: "/health", method: .get) { response in
XCTAssertEqual(response.status, .ok)
try await client.execute(uri: "/", method: .get) { response in
XCTAssertEqual(response.body, ByteBuffer(string: "Hello!"))
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,5 @@ Hummingbird server framework project
EOF

popd

echo "Enter the folder created and run 'swift run' to build and run your server. Then open 'localhost:8080' on your web browser."

0 comments on commit c995119

Please sign in to comment.