Skip to content
Browse files

Required '/' at beginning of routes.

  • Loading branch information...
1 parent a216d45 commit 9ff9dd52bb3475e2caba52497c3d70ae6f2c221f @benh benh committed Jun 23, 2012
Showing with 9 additions and 5 deletions.
  1. +8 −4 include/process/process.hpp
  2. +1 −1 src/tests.cpp
View
12 include/process/process.hpp
@@ -122,15 +122,19 @@ class ProcessBase : public EventVisitor
HttpRequestHandler;
// Setup a handler for an HTTP request.
- void route(
+ bool route(
const std::string& name,
const HttpRequestHandler& handler)
{
- handlers.http[name] = handler;
+ if (name.find('/') != 0) {
+ return false;
+ }
+ handlers.http[name.substr(1)] = handler;
+ return true;
}
template <typename T>
- void route(
+ bool route(
const std::string& name,
Future<HttpResponse> (T::*method)(const HttpRequest&))
{
@@ -140,7 +144,7 @@ class ProcessBase : public EventVisitor
HttpRequestHandler handler =
std::tr1::bind(method, dynamic_cast<T*>(this),
std::tr1::placeholders::_1);
- route(name, handler);
+ return route(name, handler);
}
// Provide the static asset(s) at the specified _absolute_ path for
View
2 src/tests.cpp
@@ -1006,7 +1006,7 @@ class HttpProcess : public Process<HttpProcess>
public:
HttpProcess()
{
- route("handler", &HttpProcess::handler);
+ route("/handler", &HttpProcess::handler);
}
MOCK_METHOD1(handler, Future<HttpResponse>(const HttpRequest&));

0 comments on commit 9ff9dd5

Please sign in to comment.
Something went wrong with that request. Please try again.