Commit 14bafd53 authored by Dennis Jenkins's avatar Dennis Jenkins

More cppcheck fixes.

parent 40a99228
...@@ -370,10 +370,10 @@ private: ...@@ -370,10 +370,10 @@ private:
struct SubPath { struct SubPath {
SubPath(std::string prefix, PathGroup* paths); SubPath(std::string prefix, PathGroup* paths);
PathBuilder route(std::string name, Http::Method method, std::string description = ""); PathBuilder route(const std::string &name, Http::Method method, std::string description = "");
PathBuilder route(PathDecl fragment, std::string description = ""); PathBuilder route(PathDecl fragment, std::string description = "");
SubPath path(std::string prefix); SubPath path(const std::string &prefix);
template<typename T> template<typename T>
void parameter(std::string name, std::string description) { void parameter(std::string name, std::string description) {
......
...@@ -203,7 +203,7 @@ SubPath::SubPath( ...@@ -203,7 +203,7 @@ SubPath::SubPath(
{ } { }
PathBuilder PathBuilder
SubPath::route(std::string name, Http::Method method, std::string description) { SubPath::route(const std::string &name, Http::Method method, std::string description) {
auto fullPath = prefix + name; auto fullPath = prefix + name;
Path path(std::move(fullPath), method, std::move(description)); Path path(std::move(fullPath), method, std::move(description));
std::copy(std::begin(parameters), std::end(parameters), std::back_inserter(path.parameters)); std::copy(std::begin(parameters), std::end(parameters), std::back_inserter(path.parameters));
...@@ -219,7 +219,7 @@ SubPath::route(PathDecl fragment, std::string description) { ...@@ -219,7 +219,7 @@ SubPath::route(PathDecl fragment, std::string description) {
} }
SubPath SubPath
SubPath::path(std::string prefix) { SubPath::path(const std::string &prefix) {
return SubPath(this->prefix + prefix, paths); return SubPath(this->prefix + prefix, paths);
} }
...@@ -397,7 +397,7 @@ Swagger::install(Rest::Router& router) { ...@@ -397,7 +397,7 @@ Swagger::install(Rest::Router& router) {
*/ */
struct Path { struct Path {
Path(const std::string& value) explicit Path(const std::string& value)
: value(value) : value(value)
, trailingSlashValue(value) , trailingSlashValue(value)
{ {
...@@ -406,32 +406,32 @@ Swagger::install(Rest::Router& router) { ...@@ -406,32 +406,32 @@ Swagger::install(Rest::Router& router) {
} }
static bool hasTrailingSlash(const Rest::Request& req) { static bool hasTrailingSlash(const Rest::Request& req) {
auto res = req.resource(); auto res_ = req.resource();
return res.back() == '/'; return res_.back() == '/';
} }
std::string stripPrefix(const Rest::Request& req) { std::string stripPrefix(const Rest::Request& req) {
auto res = req.resource(); auto res_ = req.resource();
if (!res.compare(0, value.size(), value)) { if (!res_.compare(0, value.size(), value)) {
return res.substr(value.size()); return res_.substr(value.size());
} }
return res; return res_;
} }
bool matches(const Rest::Request& req) const { bool matches(const Rest::Request& req) const {
auto res = req.resource(); auto res_ = req.resource();
if (value == res) if (value == res_)
return true; return true;
if (res == trailingSlashValue) if (res_ == trailingSlashValue)
return true; return true;
return false; return false;
} }
bool isPrefix(const Rest::Request& req) { bool isPrefix(const Rest::Request& req) {
auto res = req.resource(); auto res_ = req.resource();
return !res.compare(0, value.size(), value); return !res_.compare(0, value.size(), value);
} }
const std::string& withTrailingSlash() const { const std::string& withTrailingSlash() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment