|
25 | 25 | #include <booster/copy_ptr.h> |
26 | 26 |
|
27 | 27 | namespace cppcms { |
| 28 | + /// |
| 29 | + /// This class represents application's mount point or the rule on which specific application |
| 30 | + /// is selected to process the query. It is used by applications_pool class for mounting applications, |
| 31 | + /// and by forwarding managers to match forwarding requests |
| 32 | + /// |
28 | 33 | class CPPCMS_API mount_point { |
29 | 34 | public: |
| 35 | + /// |
| 36 | + /// Type that describes what parameter should be passed to application::main(std::string) function |
| 37 | + /// |
| 38 | + /// When the application selected specific string is passed for matching with application's member function |
| 39 | + /// or application's children. This can be CGI variable PATH_INFO or SCRIPT_NAME or their substring taken |
| 40 | + /// with regular expression. |
| 41 | + /// |
| 42 | + /// If selection is \a match_path_info then PATH_INFO passed for matching, otherwide SCRIPT_NAME is used |
| 43 | + /// for matching. |
| 44 | + /// |
| 45 | + /// For example if your service works with SCRIPT_NAME /app and the URL is pointing to /app/page/20 |
| 46 | + /// such as SCRIPT_NAME is "/app" and PATH_INFO is "/page/20" then the last one will be used for dispatching |
| 47 | + /// by cppcms::application::main function. |
| 48 | + /// |
| 49 | + /// But you may also work with "*.cgi" style URL if your application process all queries comping from |
| 50 | + /// "*.cgi" and you have "dummy scripts" at "/cgi-bin/users.cgi" and "/cgi-bin/app.cgi" and you want to match |
| 51 | + /// against SCRIPT_NAME rather then PATH_INFO you can use \a match_script_name option and the script name |
| 52 | + /// will be used for matching. |
| 53 | + /// |
30 | 54 | typedef enum { |
31 | | - match_path_info, |
32 | | - match_script_name |
| 55 | + match_path_info, ///< Pass PATH_INFO to applications |
| 56 | + match_script_name ///< Pass SCRIPT_NAME to applications |
33 | 57 | } selection_type; |
34 | 58 |
|
| 59 | + /// |
| 60 | + /// Get regular expression for HTTP_HOST CGI variable matching, if empty, no restrictions given |
| 61 | + /// |
35 | 62 | booster::regex host() const; |
| 63 | + /// |
| 64 | + /// Get regular expression for SCRIPT_NAME CGI variable matching, if empty, no restrictions given |
| 65 | + /// |
36 | 66 | booster::regex script_name() const; |
| 67 | + /// |
| 68 | + /// Get regular expression for PATH_INFO CGI variable matching, if empty, no restrictions given |
| 69 | + /// |
37 | 70 | booster::regex path_info() const; |
| 71 | + /// |
| 72 | + /// Get regular expression subgroup that is passes to application for URL dispatching |
| 73 | + /// |
38 | 74 | int group() const; |
| 75 | + |
| 76 | + /// |
| 77 | + /// Get SCRIPT_NAME/PATH_INFO selection |
| 78 | + /// |
39 | 79 | selection_type selection() const; |
40 | 80 |
|
| 81 | + /// |
| 82 | + /// Set regular expression for HTTP_HOST CGI variable matching, if empty, no restrictions given |
| 83 | + /// |
41 | 84 | void host(booster::regex const &); |
| 85 | + /// |
| 86 | + /// Set regular expression for SCRIPT_NAME CGI variable matching, if empty, no restrictions given |
| 87 | + /// |
42 | 88 | void script_name(booster::regex const &); |
| 89 | + /// |
| 90 | + /// Set regular expression for PATH_INFO CGI variable matching, if empty, no restrictions given |
| 91 | + /// |
43 | 92 | void path_info(booster::regex const &); |
| 93 | + /// |
| 94 | + /// Set regular expression subgroup that is passes to application for URL dispatching |
| 95 | + /// |
44 | 96 | void group(int); |
| 97 | + /// |
| 98 | + /// Get SCRIPT_NAME/PATH_INFO selection |
| 99 | + /// |
45 | 100 | void selection(selection_type); |
46 | 101 |
|
| 102 | + /// |
| 103 | + /// Match \a h - HTTP_HOST, \a s - SCRIPT_NAME, \a p - PATH_INFO against mount point and return |
| 104 | + /// true and selected URL path for application |
| 105 | + /// Otherwise return false and empty string |
| 106 | + /// |
47 | 107 | std::pair<bool,std::string> match(std::string const &h,std::string const &s,std::string const &p) const; |
48 | 108 |
|
| 109 | + /// |
| 110 | + /// Create default mount point, it uses PATH_INFO for url-dispatching and gives no restriction on URL |
| 111 | + /// |
49 | 112 | mount_point(); |
| 113 | + /// |
| 114 | + /// Destructor |
50 | 115 | ~mount_point(); |
| 116 | + /// |
| 117 | + /// Copy constructor |
| 118 | + /// |
51 | 119 | mount_point(mount_point const &); |
| 120 | + /// |
| 121 | + /// Assignment variable |
| 122 | + /// |
52 | 123 | mount_point const &operator=(mount_point const &); |
| 124 | + |
| 125 | + /// |
| 126 | + /// Create a mount point that checks PATH_INFO only and passes matched \a group for dispatching |
| 127 | + /// |
| 128 | + mount_point(std::string const &path,int group); |
| 129 | + /// |
| 130 | + /// Create a mount point that checks SCRIPT_NAME, and passes PATH_INFO for dispatching |
| 131 | + /// |
| 132 | + mount_point(std::string const &script); |
| 133 | + /// |
| 134 | + /// Create a mount point that checks SCRIPT_NAME, PATH_INFO only and passes matched |
| 135 | + /// PATH_INFO's \a group for dispatching |
| 136 | + /// |
| 137 | + mount_point(std::string const &script,std::string const &path,int group); |
| 138 | + |
| 139 | + /// |
| 140 | + /// Create a mount point with selection rule \a sel. |
| 141 | + /// |
| 142 | + /// \param sel -- selection rule use SCRIPT_INFO or PATH_NAME for URL based dispatching |
| 143 | + /// \param selected_part is a regular expression for matching against PATH_INFO or SCRIPT_NAME according \a sel |
| 144 | + /// \param regular expression subgroup of \a selected_part for URL dispatching |
| 145 | + /// |
| 146 | + mount_point( selection_type sel, |
| 147 | + std::string const &selected_part, |
| 148 | + int group); |
| 149 | + |
| 150 | + /// |
| 151 | + /// Create a mount point with selection rule \a sel. |
| 152 | + /// |
| 153 | + /// \param sel -- selection rule use SCRIPT_INFO or PATH_NAME for URL based dispatching |
| 154 | + /// \param non_selected_part is a regular expression for matching against PATH_INFO or SCRIPT_NAME according to |
| 155 | + /// opposite of \a sel, if sel is match_path_info then non_selected_part checked against SCRIPT_NAME |
| 156 | + /// otherwise it is checked against PATH_INFO |
| 157 | + /// |
| 158 | + mount_point( selection_type sel, |
| 159 | + std::string const &non_selected_part); |
| 160 | + |
| 161 | + /// |
| 162 | + /// Create a mount point with selection rule \a sel. |
| 163 | + /// |
| 164 | + /// \param sel -- selection rule use SCRIPT_INFO or PATH_NAME for URL based dispatching |
| 165 | + /// \param non_selected_part is a regular expression for matching against PATH_INFO or SCRIPT_NAME according to |
| 166 | + /// opposite of \a sel, if sel is match_path_info then non_selected_part checked against SCRIPT_NAME |
| 167 | + /// otherwise it is checked against PATH_INFO |
| 168 | + /// \param selected_part is a regular expression for matching against PATH_INFO or SCRIPT_NAME according \a sel |
| 169 | + /// \param regular expression subgroup of \a selected_part for URL dispatching |
| 170 | + /// |
| 171 | + mount_point( selection_type sel, |
| 172 | + std::string const &non_selected_part, |
| 173 | + std::string const &selected_part, |
| 174 | + int group); |
| 175 | + |
| 176 | + /// |
| 177 | + /// Create fully defined mount rule for matching against, \a http_host - HTTP_HOST, \a script - SCRIPT_NAME, |
| 178 | + /// \a path - PATH_INFO, and use subgroup \a group of regular expression selected with \a sel definition. |
| 179 | + /// |
| 180 | + /// Note: if regular expression is empty, no checks are performed. |
| 181 | + /// |
| 182 | + |
| 183 | + mount_point( selection_type sel, |
| 184 | + booster::regex const &http_host, |
| 185 | + booster::regex const &script, |
| 186 | + booster::regex const &path, |
| 187 | + int group); |
| 188 | + |
53 | 189 | private: |
54 | 190 | booster::regex host_; |
55 | 191 | booster::regex script_name_; |
|
0 commit comments