diff Core/RestApi/RestApiCall.h @ 1571:3232f1c995a5

provide the origin of the requests to HTTP handlers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 11:04:19 +0200
parents f3672356c121
children b1291df2f780
line wrap: on
line diff
--- a/Core/RestApi/RestApiCall.h	Sun Aug 23 11:13:03 2015 +0200
+++ b/Core/RestApi/RestApiCall.h	Tue Aug 25 11:04:19 2015 +0200
@@ -48,6 +48,9 @@
   private:
     RestApiOutput& output_;
     RestApi& context_;
+    RequestOrigin origin_;
+    const char* remoteIp_;
+    const char* username_;
     const IHttpHandler::Arguments& httpHeaders_;
     const IHttpHandler::Arguments& uriComponents_;
     const UriComponents& trailing_;
@@ -60,12 +63,18 @@
   public:
     RestApiCall(RestApiOutput& output,
                 RestApi& context,
+                RequestOrigin origin,
+                const char* remoteIp,
+                const char* username,
                 const IHttpHandler::Arguments& httpHeaders,
                 const IHttpHandler::Arguments& uriComponents,
                 const UriComponents& trailing,
                 const UriComponents& fullUri) :
       output_(output),
       context_(context),
+      origin_(origin),
+      remoteIp_(remoteIp),
+      username_(username),
       httpHeaders_(httpHeaders),
       uriComponents_(uriComponents),
       trailing_(trailing),
@@ -117,6 +126,21 @@
 
     std::string FlattenUri() const;
 
+    RequestOrigin GetRequestOrigin() const
+    {
+      return origin_;
+    }
+
+    const char* GetRemoteIp() const
+    {
+      return remoteIp_;
+    }
+
+    const char* GetUsername() const
+    {
+      return username_;
+    }
+
     virtual bool ParseJsonRequest(Json::Value& result) const = 0;
   };
 }