iFun Engine API  1.0.0-b2601
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
api_service.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2017 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_MANAGEMENT_API_SERVICE_H_
10 #define INCLUDE_FUNAPI_MANAGEMENT_API_SERVICE_H_
11 
12 #include <boost/function.hpp>
13 #include <boost/noncopyable.hpp>
14 #include <boost/regex.hpp>
16 #include <funapi/types.h>
17 
18 #include <map>
19 
20 
21 namespace fun {
22 
23 class Json;
24 
25 
26 class ApiService : public boost::noncopyable {
27  public:
28  typedef boost::smatch MatchResult;
29 
31  typedef boost::function<void(const Ptr<http::Response> &)> ResponseWriter ASSERT_NO_ROLLBACK;
32 
36  typedef boost::function<
37  void(Ptr<http::Response> ret,
38  const http::Request &request,
39  const MatchResult &params)> Handler;
40 
44  typedef boost::function<
45  void(Ptr<http::Response> ret,
46  const http::Request2 &request,
47  const MatchResult &params)> Handler2;
48 
53  typedef boost::function<
54  void(const http::Request2 &request,
55  const MatchResult &params,
56  const ResponseWriter &finisher)> Handler3;
57 
66  static void RegisterHandler(
67  const http::Method &method,
68  const boost::regex &re,
69  const Handler &handler);
70 
79  static void RegisterHandler2(
80  const http::Method &method,
81  const boost::regex &re,
82  const Handler2 &handler);
83 
92  static void RegisterHandler3(
93  const http::Method &method,
94  const boost::regex &re,
95  const Handler3 &handler);
96 
97  struct JwtVerifier : boost::noncopyable {
98  JwtVerifier();
99  virtual ~JwtVerifier();
100  virtual bool Verify(const std::string &jwt, fun::Json *claim) const = 0;
101 
102  static Ptr<JwtVerifier> Create(const std::string &public_key_pem_path);
103  };
104 
105  typedef boost::function<
106  void(const fun::Json &jwt_claim,
107  const http::Request2 &request,
108  const MatchResult &params,
109  const ResponseWriter &finisher)> JwtEnabledHandler;
110 
111  static void RegisterJwtEnabledHandler(
112  const http::Method &method,
113  const boost::regex &re,
114  const JwtEnabledHandler &handler,
115  const Ptr<JwtVerifier> &jwt_verifier);
116 };
117 
118 } // namespace fun
119 
120 #endif // INCLUDE_FUNAPI_MANAGEMENT_API_SERVICE_H_
Data structure to hold HTTP request.
Definition: http_util.h:121
static void RegisterHandler2(const http::Method &method, const boost::regex &re, const Handler2 &handler)
Register API handler for the given path regular expression.
boost::function< void(Ptr< http::Response > ret, const http::Request2 &request, const MatchResult &params)> Handler2
Definition: api_service.h:47
boost::function< void(Ptr< http::Response > ret, const http::Request &request, const MatchResult &params)> Handler
Definition: api_service.h:39
Definition: api_service.h:26
boost::function< void(const http::Request2 &request, const MatchResult &params, const ResponseWriter &finisher)> Handler3
Definition: api_service.h:56
static void RegisterHandler(const http::Method &method, const boost::regex &re, const Handler &handler)
Register API handler for the given path regular expression.
Definition: json.h:27
Definition: deploy_api_service.h:31
boost::function< void(const Ptr< http::Response > &)> ResponseWriter ASSERT_NO_ROLLBACK
Functor to send a http response and finish a http request processing.
Definition: api_service.h:31
static void RegisterHandler3(const http::Method &method, const boost::regex &re, const Handler3 &handler)
Register API handler for the given path regular expression.
Definition: api_service.h:97
Data structure to hold HTTP request.
Definition: http_util.h:108