OpenSDN source code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rest_server.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef _ROOT_REST_SERVER_H_
6 #define _ROOT_REST_SERVER_H_
7 
8 #include "base/regex.h"
9 #include "http/http_request.h"
10 #include "http/http_session.h"
12 
13 class Agent;
14 
15 class RestServer {
16  public:
17  explicit RestServer(Agent *agent);
18  virtual ~RestServer();
19 
20  void InitDone();
21  void HandleRequest(HttpSession* session, const HttpRequest* request);
22  void Shutdown();
23 
24  protected:
25  // REST handlers
26  struct RESTData {
27  const boost::smatch* match;
28  enum http_method method;
31  };
32 
34  public:
35  typedef void (RestServer::*HandlerFunc)(const struct RESTData&);
36 
38  enum http_method method,
40  : request_regex(request_regex),
41  method(method),
42  handler_func(handler_func) {}
43 
45  enum http_method method;
47  };
48 
49  static const std::vector<HandlerSpecifier> RESTHandlers_;
50 
51  void VmPortDeleteHandler(const struct RESTData&);
52  void VmPortGetHandler(const struct RESTData&);
53  void VmPortPostHandler(const struct RESTData&);
54  void VmPortSyncHandler(const struct RESTData& data);
55  void GatewayPostHandler(const struct RESTData& data);
56  void GatewayDeleteHandler(const struct RESTData& data);
57  void VmPortEnableHandler(const struct RESTData& data);
58  void VmPortDisableHandler(const struct RESTData& data);
59 
60  // Handler for VM+VN based messages
61  void VmVnPortPostHandler(const struct RESTData&);
62  void VmVnPortGetHandler(const struct RESTData&);
63  void VmVnPortDeleteHandler(const struct RESTData&);
64  void VmVnPortCfgGetHandler(const struct RESTData& data);
65 
66  private:
67  friend class RestServerGetVmCfgTask;
68 
72 };
73 
74 #endif // _ROOT_REST_SERVER_H_
void VmPortDeleteHandler(const struct RESTData &)
Definition: rest_server.cc:85
enum http_method method
Definition: rest_server.h:28
void HandleRequest(HttpSession *session, const HttpRequest *request)
Definition: rest_server.cc:319
void VmPortDisableHandler(const struct RESTData &data)
Definition: rest_server.cc:227
const HttpRequest * request
Definition: rest_server.h:30
void GatewayDeleteHandler(const struct RESTData &data)
Definition: rest_server.cc:129
static const std::vector< HandlerSpecifier > RESTHandlers_
Definition: rest_server.h:49
enum http_method method
Definition: rest_server.h:45
const boost::smatch * match
Definition: rest_server.h:27
void VmPortGetHandler(const struct RESTData &)
Definition: rest_server.cc:100
void VmPortEnableHandler(const struct RESTData &data)
Definition: rest_server.cc:212
HandlerSpecifier(const contrail::regex &request_regex, enum http_method method, HandlerFunc handler_func)
Definition: rest_server.h:37
void(RestServer::* HandlerFunc)(const struct RESTData &)
Definition: rest_server.h:35
void VmVnPortGetHandler(const struct RESTData &)
Definition: rest_server.cc:173
void VmPortSyncHandler(const struct RESTData &data)
Definition: rest_server.cc:75
void GatewayPostHandler(const struct RESTData &data)
Definition: rest_server.cc:115
RestServer(Agent *agent)
Definition: rest_server.cc:305
virtual ~RestServer()
Definition: rest_server.cc:351
Definition: agent.h:358
void VmPortPostHandler(const struct RESTData &)
Definition: rest_server.cc:61
HttpSession * session
Definition: rest_server.h:29
void VmVnPortDeleteHandler(const struct RESTData &)
Definition: rest_server.cc:158
contrail::regex request_regex
Definition: rest_server.h:44
HttpServer * http_server_
Definition: rest_server.h:70
void Shutdown()
Definition: rest_server.cc:343
Agent * agent_
Definition: rest_server.h:69
DISALLOW_COPY_AND_ASSIGN(RestServer)
void InitDone()
Definition: rest_server.cc:311
void VmVnPortPostHandler(const struct RESTData &)
Definition: rest_server.cc:144
void VmVnPortCfgGetHandler(const struct RESTData &data)
Definition: rest_server.cc:200