Skip to content

Instantly share code, notes, and snippets.

@owensd

owensd/vapor.swift Secret

Created Apr 21, 2017
Embed
What would you like to do?
let drop = Droplet()
drop.get("/v1/api/spells/:name") { req in
let name = try req.parameters.extract("name") as String
return SpellRouter.api(name: name).json
}
drop.get("/spells/:name") { req in
let name = try req.parameters.extract("name") as String
let partial = req.query?["partial"]?.bool ?? false
let res = SpellRouter.get(name: name)
return partial ? res.partialHtml : res.html
}
drop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment