Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cloutiertyler committed Nov 21, 2016
2 parents 4445e1d + dcb6d16 commit 6b25055
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,13 @@ api.get("/users") { request in
return Response(status: .ok)
}

// Filter requests under api that match "/auth". If it's a POST
// request at "/auth/login" return a 200 OK response.
// NOTE: Equivalent to `api.post("/auth/login")`
let auth = api.filter("/auth").post("/login") { request in
return Response(status: .ok)
}
api.add(auth)

// Create the top level router and add simple middleware
// which logs all requests.
// Middleware to log all requests
// NOTE: Middleware is a simple as a map function or closure!
let app = Router().map { request in
print(request)
Expand All @@ -80,10 +77,7 @@ let app = Router().map { request in
// Mount the API router under "/v1.0".
app.add("/v1.0", api)

// Handle all other requests with a 404 NOT FOUND error.
// NOTE: Any unhandled responses with throw an error.
// This means clear error messages and no more accidentally
// timing out clients!
// NOTE: Errors on all unhandled requests. No more hanging clients!
app.any { _ in
return Response(status: .notFound)
}
Expand Down Expand Up @@ -147,7 +141,7 @@ server.listen().startWithNext { connection in
print("Goodbye \(connection)!")
}

byteStream.start()
strings.start()
}

RunLoop.runAll()
Expand Down

0 comments on commit 6b25055

Please sign in to comment.