This file contains 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
fws::service service; | |
service.get("/v1/api/spells/:name", [](fws::http_request req) { | |
auto nameit = req.parameters.find("name"); | |
if (nameit == req.parameters.end()) { | |
// bad request | |
return fws::http_response(); | |
} | |
else { | |
auto name = nameit->first; | |
return spells::api(name); | |
} | |
}); | |
service.get("/spells/:name", [](fws::http_request req) { | |
auto nameit = req.parameters.find("name"); | |
auto partialit = req.query.find("partial"); | |
if (nameit == req.parameters.end()) { | |
// bad request | |
return fws::http_response(); | |
} | |
bool partial = false; | |
if (partialit != req.query.end()) { | |
auto value = partialit->first; | |
partial = (value == "true" || value == "yes"); | |
} | |
return spells::view(nameit->first, partial); | |
}); | |
service.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment