Skip to content

Instantly share code, notes, and snippets.

@owensd

owensd/server1.cpp Secret

Created Apr 21, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.