Skip to content

Commit

Permalink
IBM-Swift/Kitura-router#13 Added static file server middleware to the…
Browse files Browse the repository at this point in the history
… sample. Removed router.all.
  • Loading branch information
irar2 committed Mar 8, 2016
1 parent e6e0d9f commit 3de51d7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions Sources/KituraSample/main.swift
Expand Up @@ -61,6 +61,8 @@ class BasicAuthMiddleware: RouterMiddleware {
// This route executes the echo middleware
router.use("/*", middleware: BasicAuthMiddleware())

router.use("/static/*", middleware: StaticFileServer())

router.get("/hello") { _, response, next in
response.setHeader("Content-Type", value: "text/plain; charset=utf-8")
do {
Expand Down Expand Up @@ -181,16 +183,6 @@ router.error { request, response, next in
next()
}

// Accepts any other routes that couldn't be matched and returns a 404 error
router.all { request, response, next in
do {
try response.status(HttpStatusCode.NOT_FOUND).send("Route not found in sample application").end()
}
catch{}
next()
}


// Listen on port 8090
let server = HttpServer.listen(8090,
delegate: router)
Expand Down

0 comments on commit 3de51d7

Please sign in to comment.