Created
February 10, 2016 02:09
-
-
Save unnamedd/759bca027b076094d57a to your computer and use it in GitHub Desktop.
Basic Authentication Middleware - Zewo - Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Flux | |
var basicAuth = BasicAuthenticationMiddleware(username: "admin", password: "password") | |
let router = Router(middleware: logger, basicAuth) { route in | |
route.get("/") { request in | |
var content: [String: InterchangeData] = ["id": 2348, "title": "Blood Brother", "artist": "Iron Maiden"] | |
let serializedContent = PrettyJSONSerializer().serializeObject(content) | |
var response = Response(status: .OK, body: serializedContent) | |
response.headers["Content-Type"] = "application/json" | |
return response | |
} | |
} | |
try HTTPServer(port: 8081, responder: router).start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment