NEC mBaaS Embedded SDK  6.2.0
 全て クラス ネームスペース ファイル 関数 変数 列挙型 列挙型の値
nb_api_gateway.h
説明を見る。
1 /*
2  * COPYRIGHT (C) 2017 NEC CORPORATION
3  *
4  * ALL RIGHTS RESERVED BY NEC CORPORATION, THIS PROGRAM
5  * MUST BE USED SOLELY FOR THE PURPOSE FOR WHICH IT WAS
6  * FURNISHED BY NEC CORPORATION, NO PART OF THIS PROGRAM
7  * MAY BE REPRODUCED OR DISCLOSED TO OTHERS, IN ANY FORM
8  * WITHOUT THE PRIOR WRITTEN PERMISSION OF NEC CORPORATION.
9  *
10  * NEC CONFIDENTIAL AND PROPRIETARY
11  */
12 
13 #ifndef NECBAAS_NBAPIGATEWAY_H
14 #define NECBAAS_NBAPIGATEWAY_H
15 
16 #include <string>
17 #include <memory>
18 #include <vector>
19 #include <map>
20 #include "necbaas/nb_service.h"
21 
22 namespace necbaas {
23 
30 class NbApiGateway {
31  public:
39  NbApiGateway(const std::shared_ptr<NbService> &service, const std::string &api_name,
40  NbHttpRequestMethod http_method, const std::string &subpath = "");
41 
45  ~NbApiGateway();
46 
56  NbResult<NbHttpResponse> ExecuteCustomApi(const std::string &body = "");
57 
67  NbResult<NbHttpResponse> ExecuteCustomApi(const std::vector<char> &body);
68 
73  int GetTimeout() const;
74 
81  void SetTimeout(int timeout);
82 
87  const std::multimap<std::string, std::string> &GetHeaders() const;
88 
106  void AddHeader(const std::string &name, const std::string &value);
107 
115  int RemoveHeader(const std::string &name);
116 
121  void ClearHeaders();
122 
127  const std::multimap<std::string, std::string> &GetParameters() const;
128 
137  void AddParameter(const std::string &name, const std::string &value);
138 
146  int RemoveParameter(const std::string &name);
147 
152  void ClearParameters();
153 
158  const std::string &GetContentType() const;
159 
165  void SetContentType(const std::string &content_type);
166 
167  private:
168  std::shared_ptr<NbService> service_;
169  int timeout_{kRestTimeoutDefault};
170  std::string api_name_;
171  NbHttpRequestMethod http_method_;
172  std::string subpath_;
173  std::multimap<std::string, std::string> parameters_;
174  std::multimap<std::string, std::string> headers_;
175  std::string content_type_;
185  bool CheckContentType(const std::string &body);
186 
194  void AppendContentType(const std::string &body, NbHttpRequestFactory *request_factory);
195 
204  bool IsReservedHeaderName(const std::string &name) const;
205 };
206 } // namespace necbaas
207 #endif // NECBAAS_NBAPIGATEWAY_H
const std::multimap< std::string, std::string > & GetParameters() const
リクエストパラメータリスト取得.
int GetTimeout() const
RESTタイムアウト取得.
~NbApiGateway()
デストラクタ.
NbResult< NbHttpResponse > ExecuteCustomApi(const std::string &body="")
カスタムAPI実行.
API Gatewayクラス.
Definition: nb_api_gateway.h:30
void SetContentType(const std::string &content_type)
Content-Type設定.
int RemoveParameter(const std::string &name)
リクエストパラメータ削除.
void AddParameter(const std::string &name, const std::string &value)
リクエストパラメータ追加.
void AddHeader(const std::string &name, const std::string &value)
HTTPヘッダ追加.
NbHttpRequestMethod
HTTPリクエストメソッド.
Definition: nb_http_request_method.h:21
void ClearParameters()
リクエストパラメータクリア.
REST API処理結果クラス.
Definition: nb_result.h:32
void SetTimeout(int timeout)
RESTタイムアウト設定.
const std::string & GetContentType() const
Content-Type取得.
const std::multimap< std::string, std::string > & GetHeaders() const
HTTPヘッダリスト取得.
NbApiGateway(const std::shared_ptr< NbService > &service, const std::string &api_name, NbHttpRequestMethod http_method, const std::string &subpath="")
コンストラクタ.
void ClearHeaders()
HTTPヘッダクリア.
int RemoveHeader(const std::string &name)
HTTPヘッダ削除.