iFun Engine API  1.0.0-b6053
Great Technology for Great Games
api_service.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 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 FUNAPI_DLL_VISIBILITY ApiService : public boost::noncopyable {
27  public:
28  typedef boost::smatch MatchResult;
29 
31  typedef boost::function<void(
32  const Ptr<http::Response> &)> ResponseWriter ASSERT_NO_ROLLBACK;
33 
37  typedef boost::function<
38  void(Ptr<http::Response> ret,
39  const http::Request &request,
40  const MatchResult &params)> Handler;
41 
45  typedef boost::function<
46  void(Ptr<http::Response> ret,
47  const http::Request2 &request,
48  const MatchResult &params)> Handler2;
49 
54  typedef boost::function<
55  void(const http::Request2 &request,
56  const MatchResult &params,
57  const ResponseWriter &finisher)> Handler3;
58 
67  static void RegisterHandler(
68  const http::Method &method,
69  const boost::regex &re,
70  const Handler &handler);
71 
80  static void RegisterHandler2(
81  const http::Method &method,
82  const boost::regex &re,
83  const Handler2 &handler);
84 
93  static void RegisterHandler3(
94  const http::Method &method,
95  const boost::regex &re,
96  const Handler3 &handler);
97 
98  struct FUNAPI_DLL_VISIBILITY JwtVerifier : boost::noncopyable {
99  JwtVerifier();
100  virtual ~JwtVerifier();
101  virtual bool Verify(const std::string &jwt, fun::Json *claim) const = 0;
102 
103  static Ptr<JwtVerifier> Create(const std::string &public_key_pem_path);
104  };
105 
106  typedef boost::function<
107  void(const fun::Json &jwt_claim,
108  const http::Request2 &request,
109  const MatchResult &params,
110  const ResponseWriter &finisher)> JwtEnabledHandler;
111 
112  static void RegisterJwtEnabledHandler(
113  const http::Method &method,
114  const boost::regex &re,
115  const JwtEnabledHandler &handler,
116  const Ptr<JwtVerifier> &jwt_verifier);
117 };
118 
119 } // namespace fun
120 
121 #endif // INCLUDE_FUNAPI_MANAGEMENT_API_SERVICE_H_
Data structure to hold HTTP request.
Definition: http_util.h:123
boost::function< void(Ptr< http::Response > ret, const http::Request2 &request, const MatchResult &params)> Handler2
Definition: api_service.h:48
boost::function< void(Ptr< http::Response > ret, const http::Request &request, const MatchResult &params)> Handler
Definition: api_service.h:40
Definition: json.h:18
Definition: api_service.h:26
boost::function< void(const http::Request2 &request, const MatchResult &params, const ResponseWriter &finisher)> Handler3
Definition: api_service.h:57
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:32
Definition: json.h:27
Definition: deploy_api_service.h:31
Method
Enum type representing HTTP methods.
Definition: http_util.h:34
Definition: api_service.h:98
Data structure to hold HTTP request.
Definition: http_util.h:109