RESTinio
express.hpp
Go to the documentation of this file.
1 /*
2  restinio
3 */
4 
5 /*!
6  Express.js style router.
7 */
8 
9 #pragma once
10 
11 #include <restinio/router/impl/target_path_holder.hpp>
12 #include <restinio/router/non_matched_request_handler.hpp>
13 
14 #include <restinio/path2regex/path2regex.hpp>
15 
16 #include <restinio/router/std_regex_engine.hpp>
17 #include <restinio/router/method_matcher.hpp>
18 
19 #include <restinio/utils/from_string.hpp>
20 #include <restinio/utils/percent_encoding.hpp>
21 
22 #include <map>
23 #include <optional>
24 #include <vector>
25 
26 namespace restinio
27 {
28 
29 namespace router
30 {
31 
32 namespace impl
33 {
34 
36 
37 } /* namespace impl */
38 
39 //
40 // route_params_t
41 //
42 
43 //! Parameters extracted from route.
44 /*!
45  Holds values of parameters extracted from route.
46 
47  All values are stored as string views,
48  route_params_t instance owns bufers used by these views.
49  And that leads to following limittions:
50  once a copy of a string view is created it is
51  important to use it with respect to life time of route_params_t
52  instance to which this parameter bind belongs.
53  String view is valid during route_params_t
54  instance life time.
55 */
56 class route_params_t final
57 {
58  public:
59  using named_parameters_container_t =
60  std::vector< std::pair< string_view_t, string_view_t > >;
61  using indexed_parameters_container_t =
62  std::vector< string_view_t >;
63 
64  private:
65  friend struct impl::route_params_accessor_t;
66 
67  void
69  std::unique_ptr< char[] > request_target,
70  std::shared_ptr< std::string > key_names_buffer,
71  string_view_t match,
72  named_parameters_container_t named_parameters,
73  indexed_parameters_container_t indexed_parameters )
74  {
75  m_request_target = std::move( request_target );
76  m_key_names_buffer = std::move( key_names_buffer );
77  m_match = match;
78  m_named_parameters = std::move( named_parameters );
79  m_indexed_parameters = std::move( indexed_parameters );
80  }
81 
82  public:
83  route_params_t() = default;
84 
85  route_params_t( route_params_t && ) = default;
86  route_params_t & operator = ( route_params_t && ) = default;
87 
88  route_params_t( const route_params_t & ) = delete;
89  route_params_t & operator = ( const route_params_t & ) = delete;
90 
91  //! Matched route.
92  string_view_t match() const noexcept { return m_match; }
93 
94  //! Get named parameter.
96  operator [] ( string_view_t key ) const
97  {
98  return find_named_parameter_with_check( key ).second;
99  }
100 
101  //! Check parameter.
102  bool
103  has( string_view_t key ) const noexcept
104  {
105  return m_named_parameters.end() != find_named_parameter( key );
106  }
107 
108  //! Get the value of a parameter if it exists.
109  //! @since v.0.4.4
111  get_param( string_view_t key ) const noexcept
112  {
113  const auto it = find_named_parameter( key );
114 
115  return m_named_parameters.end() != it ?
116  std::optional< string_view_t >{ it->second } :
117  std::optional< string_view_t >{ std::nullopt };
118  }
119 
120  //! Get indexed parameter.
122  operator [] ( std::size_t i ) const
123  {
124  if( i >= m_indexed_parameters.size() )
125  throw exception_t{
126  fmt::format(
127  RESTINIO_FMT_FORMAT_STRING( "invalid parameter index: {}" ),
128  i )
129  };
130 
131  return m_indexed_parameters.at( i );
132  }
133 
134  //! Get number of parameters.
135  //! \{
136  auto named_parameters_size() const noexcept { return m_named_parameters.size(); }
137  auto indexed_parameters_size() const noexcept { return m_indexed_parameters.size(); }
138  //! \}
139 
140  private:
143  {
144  return
145  std::find_if(
146  m_named_parameters.begin(),
147  m_named_parameters.end(),
148  [&]( const auto p ){
149  return key == p.first;
150  } );
151  }
152 
155  {
156  auto it = find_named_parameter( key );
157 
158  if( m_named_parameters.end() == it )
159  throw exception_t{
160  fmt::format(
161  RESTINIO_FMT_FORMAT_STRING( "invalid parameter name: {}" ),
162  std::string{ key.data(), key.size() } ) };
163 
164  return *it;
165  }
166 
167  //! A raw request target.
168  /*!
169  All parameters values are defined as string views
170  refering parts of this beffer.
171 
172  \note `std::unique_ptr< char[] >` is used here on purpose,
173  because if we consider std::string, then it has an issue
174  when SSO is applied. It is important that
175  parameters that refering buffer are valid after move operations with
176  the buffer. And std::strings with SSO applied cannot guarantee this.
177  Vector on the other hand gives this guarantee.
178  */
180 
181  //! Shared buffer for string_view of named parameterts names.
183 
184  //! Matched pattern.
186 
187  //! Named params.
189 
190  //! Indexed params.
192 };
193 
194 namespace impl
195 {
196 
197 //
198 // route_params_accessor_t
199 //
200 
201 //! Route params private internals accessor.
203 {
204  //! Init parameters with a matched route params.
205  static void
207  route_params_t & rp,
208  std::unique_ptr< char[] > request_target,
209  std::shared_ptr< std::string > key_names_buffer,
210  string_view_t match_,
211  route_params_t::named_parameters_container_t named_parameters,
212  route_params_t::indexed_parameters_container_t indexed_parameters )
213  {
214  rp.match(
215  std::move( request_target ),
216  std::move( key_names_buffer ),
217  match_,
218  std::move( named_parameters ),
219  std::move( indexed_parameters ) );
220  }
221 
222  //! Get values containers for all parameters (used in unit tests).
223  //! \{
224  static const auto &
225  named_parameters( const route_params_t & rp ) noexcept
226  {
227  return rp.m_named_parameters;
228  }
229 
230  static const auto &
231  indexed_parameters( const route_params_t & rp ) noexcept
232  {
233  return rp.m_indexed_parameters;
234  }
235  //! \}
236 };
237 
238 //
239 // route_params_appender_t
240 //
241 
242 //! Helper class for gthering parameters from route.
244 {
245  public:
247  route_params_t::named_parameters_container_t & named_parameters,
248  route_params_t::indexed_parameters_container_t & indexed_parameters )
251  {}
252 
257 
258  void
259  add_named_param( string_view_t key, string_view_t value )
260  {
261  m_named_parameters.emplace_back( key, value );
262  }
263 
264  void
265  add_indexed_param( string_view_t value )
266  {
267  m_indexed_parameters.emplace_back( value );
268  }
269 
270  private:
273 };
274 
277 
278 //
279 // route_matcher_t
280 //
281 
282 //! A matcher for a given path.
283 template < typename Regex_Engine = std_regex_engine_t >
285 {
286  public:
287  using regex_t = typename Regex_Engine::compiled_regex_t;
288  using match_results_t = typename Regex_Engine::match_results_t;
289 
290  //! Creates matcher with a given parameters.
292  http_method_id_t method,
293  regex_t route_regex,
294  std::shared_ptr< std::string > named_params_buffer,
295  param_appender_sequence_t param_appender_sequence )
299  {
301  }
302 
303  /*!
304  * Creates matcher with a given parameters.
305  *
306  * This constructor is intended for cases where method_matcher is
307  * specified as object of class derived from method_matcher_t.
308  *
309  * @since v.0.6.6
310  */
311  template< typename Method_Matcher >
313  Method_Matcher && method_matcher,
314  regex_t route_regex,
315  std::shared_ptr< std::string > named_params_buffer,
316  param_appender_sequence_t param_appender_sequence )
320  {
321  assign(
324  }
325 
326  route_matcher_t() = default;
327  route_matcher_t( route_matcher_t && ) = default;
328 
329  //! Try to match a given request target with this route.
330  bool
332  target_path_holder_t & target_path,
333  route_params_t & parameters ) const
334  {
336  if( Regex_Engine::try_match(
337  target_path.view(),
339  matches ) )
340  {
342 
343  // Data for route_params_t initialization.
344 
346 
347  const string_view_t match{
351 
354 
356 
357  // Std regex and pcre engines handle
358  // trailing groups with empty values differently.
359  // Std despite they are empty includes them in the list of match results;
360  // Pcre on the other hand does not.
361  // So the second for is for pushing empty values
362  std::size_t i = 1;
363  for( ; i < matches.size(); ++i )
364  {
365  const auto & m = matches[ i ];
372  }
373 
374  for( ; i < m_param_appender_sequence.size() + 1; ++i )
375  {
379  }
380 
381  // Init route parameters.
383  parameters,
385  m_named_params_buffer, // Do not move (it is used on each match).
386  std::move( match ),
389 
390  return true;
391  }
392 
393  return false;
394  }
395 
396  inline bool
397  operator () (
398  const http_request_header_t & h,
399  target_path_holder_t & target_path,
400  route_params_t & parameters ) const
401  {
402  return m_method_matcher->match( h.method() ) &&
404  }
405 
406  private:
407  //! HTTP method to match.
409 
410  //! Regex of a given route.
411  regex_t m_route_regex;
412 
413  //! Buffer for named parameters names string views.
415 
416  //! Parameters values.
418 };
419 
420 } /* namespace impl */
421 
422 //
423 // generic_express_request_handler_t
424 //
425 /*!
426  * @brief Type of generic handler for one route.
427  *
428  * Since v.0.6.13 some extra-data can be incorporated into request-object.
429  * In that case request-handler will have a different format in
430  * comparison with previous versions. The type generic_express_request_handler_t
431  * describes a request-handler when extra-data of type @a Extra_Data is
432  * bound to request object.
433  *
434  * @note
435  * If the default extra-data-factory in specified in server's traits
436  * then the old type express_request_handler_t can be used for
437  * the simplicity.
438  *
439  * @since v.0.6.13
440  */
441 template< typename Extra_Data >
446  >;
447 
448 //
449 // express_request_handler_t
450 //
451 /*!
452  * @brief Type of a handler for one route in the case when there is
453  * no extra-data in request object.
454  *
455  * Since v.0.6.13 it's just an alias for generic_express_request_handler_t
456  * for the case when the default extra-data-factory is used in
457  * server's traits.
458  */
461 
462 //
463 // generic_express_route_entry_t
464 //
465 
466 //! A single generic express route entry.
467 /*!
468  Might be helpful for use without express_router_t,
469  if only a single route is needed.
470  It gives the same help with route parameters.
471 */
472 template<
473  typename Regex_Engine,
474  typename Extra_Data_Factory >
476 {
477  public:
479  typename Extra_Data_Factory::data_t
480  >;
482  typename Extra_Data_Factory::data_t
483  >;
484 
485  private:
486  using matcher_init_data_t =
490 
491  template< typename Method_Matcher >
493  Method_Matcher && method_matcher,
494  matcher_init_data_t matcher_data,
495  actual_request_handler_t handler )
496  : m_matcher{
501  , m_handler{ std::move( handler ) }
502  {}
503 
504  public:
506  const generic_express_route_entry_t & ) = delete;
508  const generic_express_route_entry_t & ) = delete;
509 
510  generic_express_route_entry_t() = default;
512  generic_express_route_entry_t && ) = default;
513 
515  operator=( generic_express_route_entry_t && ) = default;
516 
517  template< typename Method_Matcher >
519  Method_Matcher && method_matcher,
520  string_view_t route_path,
521  const path2regex::options_t & options,
522  actual_request_handler_t handler )
526  route_path,
527  options ),
528  std::move( handler ) }
529  {}
530 
531  template< typename Method_Matcher >
533  Method_Matcher && method_matcher,
534  string_view_t route_path,
535  actual_request_handler_t handler )
538  route_path,
540  std::move( handler ) }
541  {}
542 
543  //! Checks if request header matches entry,
544  //! and if so, set route params.
545  [[nodiscard]]
546  bool
548  const http_request_header_t & h,
549  impl::target_path_holder_t & target_path,
550  route_params_t & params ) const
551  {
552  return m_matcher( h, target_path, params );
553  }
554 
555  //! Calls a handler of given request with given params.
556  [[nodiscard]]
559  {
560  return m_handler( std::move( rh ), std::move( rp ) );
561  }
562 
563  private:
564  impl::route_matcher_t< Regex_Engine > m_matcher;
566 };
567 
568 //
569 // express_route_entry_t
570 //
571 /*!
572  * @brief An alias for a single route entry in the case when the default
573  * extra-data-factory is used in server's traits.
574  *
575  * Since v.0.6.13 this name is just an alias for generic_express_route_entry_t.
576  */
577 template<
578  typename Regex_Engine = std_regex_engine_t >
580  Regex_Engine,
582 
583 //
584 // generic_express_router_t
585 //
586 
587 //! Generic Express.js style router.
588 /*!
589  Express routers acts as a request handler (it means it is a function-object
590  that can be called as a restinio request handler). It aggregates several
591  endpoint-handlers and picks one or none of them to handle the request. The
592  choice of the handler to execute depends on request target and HTTP method.
593 
594  If router finds no handler matching the request then request is considered
595  unmatched.
596 
597  It is possible to set a handler for unmatched requests, otherwise router
598  rejects the request and RESTinio takes care of it.
599 
600  There is a difference between ordinary restinio request handler and the one
601  that is used with experss router: generic_express_request_handler_t. The
602  signature of a handlers that can be put in router has an additional
603  parameter -- a container with parameters extracted from URI (request
604  target).
605 
606  @tparam Regex_Engine Type of regex-engine to be used.
607 
608  @tparam Extra_Data_Factory Type of extra-data-factory specified in
609  server's traits.
610 */
611 template<
612  typename Regex_Engine,
613  typename Extra_Data_Factory >
615 {
616  public:
619  using actual_request_handler_t =
621  Regex_Engine,
622  Extra_Data_Factory
623  >::actual_request_handler_t;
624  using non_matched_handler_t =
626  typename Extra_Data_Factory::data_t
627  >;
628 
629  generic_express_router_t() = default;
631 
632  [[nodiscard]]
635  {
638  for( const auto & entry : m_handlers )
639  {
640  if( entry.match( req->header(), target_path, params ) )
641  {
642  return entry.handle( std::move( req ), std::move( params ) );
643  }
644  }
645 
646  // Here: none of the routes matches this handler.
647 
649  {
650  // If non matched request handler is set
651  // then call it.
653  }
654 
655  return request_not_handled();
656  }
657 
658  //! Add handlers.
659  //! \{
660  template< typename Method_Matcher >
661  void
663  Method_Matcher && method_matcher,
664  string_view_t route_path,
665  actual_request_handler_t handler )
666  {
667  add_handler(
669  route_path,
671  std::move( handler ) );
672  }
673 
674  template< typename Method_Matcher >
675  void
677  Method_Matcher && method_matcher,
678  string_view_t route_path,
679  const path2regex::options_t & options,
680  actual_request_handler_t handler )
681  {
684  route_path,
685  options,
686  std::move( handler ) );
687  }
688 
689  void
691  string_view_t route_path,
692  actual_request_handler_t handler )
693  {
694  add_handler(
696  route_path,
697  std::move( handler ) );
698  }
699 
700  void
702  string_view_t route_path,
703  const path2regex::options_t & options,
704  actual_request_handler_t handler )
705  {
706  add_handler(
708  route_path,
709  options,
710  std::move( handler ) );
711  }
712 
713  void
715  string_view_t route_path,
716  actual_request_handler_t handler )
717  {
718  add_handler(
719  http_method_get(),
720  route_path,
721  std::move( handler ) );
722  }
723 
724  void
726  string_view_t route_path,
727  const path2regex::options_t & options,
728  actual_request_handler_t handler )
729  {
730  add_handler(
731  http_method_get(),
732  route_path,
733  options,
734  std::move( handler ) );
735  }
736 
737  void
739  string_view_t route_path,
740  actual_request_handler_t handler )
741  {
742  add_handler(
744  route_path,
745  std::move( handler ) );
746  }
747 
748  void
750  string_view_t route_path,
751  const path2regex::options_t & options,
752  actual_request_handler_t handler )
753  {
754  add_handler(
756  route_path,
757  options,
758  std::move( handler ) );
759  }
760 
761  void
763  string_view_t route_path,
764  actual_request_handler_t handler )
765  {
766  add_handler(
768  route_path,
769  std::move( handler ) );
770  }
771 
772  void
774  string_view_t route_path,
775  const path2regex::options_t & options,
776  actual_request_handler_t handler )
777  {
778  add_handler(
780  route_path,
781  options,
782  std::move( handler ) );
783  }
784 
785  void
787  string_view_t route_path,
788  actual_request_handler_t handler )
789  {
790  add_handler(
791  http_method_put(),
792  route_path,
793  std::move( handler ) );
794  }
795 
796  void
798  string_view_t route_path,
799  const path2regex::options_t & options,
800  actual_request_handler_t handler )
801  {
802  add_handler(
803  http_method_put(),
804  route_path,
805  options,
806  std::move( handler ) );
807  }
808  //! \}
809 
810  //! Set handler for requests that don't match any route.
811  void
812  non_matched_request_handler( non_matched_handler_t nmrh )
813  {
815  }
816 
817  private:
818  using route_entry_t = generic_express_route_entry_t<
819  Regex_Engine,
820  Extra_Data_Factory
821  >;
822 
823  //! A list of existing routes.
825 
826  //! Handler that is called for requests that don't match any route.
828 };
829 
830 //
831 // express_router_t
832 //
833 /*!
834  * @brief A type of express-like router for the case when the default
835  * extra-data-factory is specified in the server's traits.
836  *
837  * Since v.0.6.13 this type is just an alias for generic_express_router_t
838  * with the default extra-data-factory type.
839  *
840  * @tparam Regex_Engine Type of regex-engine to be used.
841  */
842 template<
843  typename Regex_Engine = std_regex_engine_t >
845  Regex_Engine,
847 
848 } /* namespace router */
849 
850 //! Cast named parameter value to a given type.
851 template < typename Value_Type >
852 Value_Type
853 get( const router::route_params_t & params, string_view_t key )
854 {
855  return std::get< Value_Type >( params[ key ] );
856 }
857 
858 //! Cast indexed parameter value to a given type.
859 template < typename Value_Type >
860 Value_Type
861 get( const router::route_params_t & params, std::size_t index )
862 {
863  return std::get< Value_Type >( params[ index ] );
864 }
865 
866 } /* namespace restinio */
static const auto & indexed_parameters(const route_params_t &rp) noexcept
Definition: express.hpp:231
generic_express_route_entry_t(generic_express_route_entry_t &&)=default
route_params_appender_t(route_params_t::named_parameters_container_t &named_parameters, route_params_t::indexed_parameters_container_t &indexed_parameters)
Definition: express.hpp:246
string_view_t operator[](std::size_t i) const
Get indexed parameter.
Definition: express.hpp:122
generic_express_route_entry_t & operator=(const generic_express_route_entry_t &)=delete
void http_head(string_view_t route_path, actual_request_handler_t handler)
Definition: express.hpp:738
bool match(const http_request_header_t &h, impl::target_path_holder_t &target_path, route_params_t &params) const
Checks if request header matches entry, and if so, set route params.
Definition: express.hpp:547
void non_matched_request_handler(non_matched_handler_t nmrh)
Set handler for requests that don&#39;t match any route.
Definition: express.hpp:812
void add_indexed_param(string_view_t value)
Definition: express.hpp:265
void http_head(string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:749
route_matcher_t(route_matcher_t &&)=default
generic_express_route_entry_t()=default
Route params private internals accessor.
Definition: express.hpp:202
request_handling_status_t operator()(actual_request_handle_t req) const
Definition: express.hpp:634
route_params_t & operator=(route_params_t &&)=default
void add_named_param(string_view_t key, string_view_t value)
Definition: express.hpp:259
route_matcher_t(http_method_id_t method, regex_t route_regex, std::shared_ptr< std::string > named_params_buffer, param_appender_sequence_t param_appender_sequence)
Creates matcher with a given parameters.
Definition: express.hpp:291
regex_t m_route_regex
Regex of a given route.
Definition: express.hpp:411
void http_put(string_view_t route_path, actual_request_handler_t handler)
Definition: express.hpp:786
auto indexed_parameters_size() const noexcept
Definition: express.hpp:137
actual_request_handler_t m_handler
Definition: express.hpp:565
std::shared_ptr< std::string > m_named_params_buffer
Buffer for named parameters names string views.
Definition: express.hpp:414
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, std::optional< Value_Type > >::type opt_value(const Parameter_Container &params, string_view_t key)
Gets the value of a parameter specified by key wrapped in std::optional<Value_Type> if parameter exis...
Definition: value_or.hpp:64
auto named_parameters_size() const noexcept
Get number of parameters.
Definition: express.hpp:136
bool match_route(target_path_holder_t &target_path, route_params_t &parameters) const
Try to match a given request target with this route.
Definition: express.hpp:331
std::optional< string_view_t > get_param(string_view_t key) const noexcept
Get the value of a parameter if it exists.
Definition: express.hpp:111
std::shared_ptr< std::string > m_key_names_buffer
Shared buffer for string_view of named parameterts names.
Definition: express.hpp:182
A single generic express route entry.
Definition: express.hpp:475
std::unique_ptr< char[] > m_request_target
A raw request target.
Definition: express.hpp:179
generic_express_route_entry_t(Method_Matcher &&method_matcher, string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:518
static const auto & named_parameters(const route_params_t &rp) noexcept
Get values containers for all parameters (used in unit tests).
Definition: express.hpp:225
named_parameters_container_t::const_reference find_named_parameter_with_check(string_view_t key) const
Definition: express.hpp:154
static void match(route_params_t &rp, std::unique_ptr< char[] > request_target, std::shared_ptr< std::string > key_names_buffer, string_view_t match_, route_params_t::named_parameters_container_t named_parameters, route_params_t::indexed_parameters_container_t indexed_parameters)
Init parameters with a matched route params.
Definition: express.hpp:206
indexed_parameters_container_t m_indexed_parameters
Indexed params.
Definition: express.hpp:191
generic_express_route_entry_t & operator=(generic_express_route_entry_t &&)=default
string_view_t m_match
Matched pattern.
Definition: express.hpp:185
void http_get(string_view_t route_path, actual_request_handler_t handler)
Definition: express.hpp:714
void http_put(string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:797
A matcher for a given path.
Definition: express.hpp:284
impl::route_matcher_t< Regex_Engine > m_matcher
Definition: express.hpp:564
void add_handler(Method_Matcher &&method_matcher, string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:676
route_params_t(route_params_t &&)=default
named_parameters_container_t m_named_parameters
Named params.
Definition: express.hpp:188
generic_express_route_entry_t(const generic_express_route_entry_t &)=delete
generic_express_router_t(generic_express_router_t &&)=default
Value_Type get(const router::route_params_t &params, std::size_t index)
Cast indexed parameter value to a given type.
Definition: express.hpp:861
string_view_t match() const noexcept
Matched route.
Definition: express.hpp:92
route_params_t & operator=(const route_params_t &)=delete
route_matcher_t(Method_Matcher &&method_matcher, regex_t route_regex, std::shared_ptr< std::string > named_params_buffer, param_appender_sequence_t param_appender_sequence)
Definition: express.hpp:312
route_params_appender_t & operator=(const route_params_appender_t &)=delete
route_params_t::named_parameters_container_t & m_named_parameters
Definition: express.hpp:271
route_params_appender_t & operator=(route_params_appender_t &&)=delete
route_params_appender_t(const route_params_appender_t &)=delete
param_appender_sequence_t m_param_appender_sequence
Parameters values.
Definition: express.hpp:417
bool operator()(const http_request_header_t &h, target_path_holder_t &target_path, route_params_t &parameters) const
Definition: express.hpp:397
std::vector< route_entry_t > m_handlers
A list of existing routes.
Definition: express.hpp:824
bool has(string_view_t key) const noexcept
Check parameter.
Definition: express.hpp:103
void add_handler(Method_Matcher &&method_matcher, string_view_t route_path, actual_request_handler_t handler)
Add handlers.
Definition: express.hpp:662
named_parameters_container_t::const_iterator find_named_parameter(string_view_t key) const noexcept
Definition: express.hpp:142
Generic Express.js style router.
Definition: express.hpp:614
void match(std::unique_ptr< char[] > request_target, std::shared_ptr< std::string > key_names_buffer, string_view_t match, named_parameters_container_t named_parameters, indexed_parameters_container_t indexed_parameters)
Definition: express.hpp:68
Helper class for gthering parameters from route.
Definition: express.hpp:243
request_handling_status_t handle(actual_request_handle_t rh, route_params_t rp) const
Calls a handler of given request with given params.
Definition: express.hpp:558
non_matched_handler_t m_non_matched_request_handler
Handler that is called for requests that don&#39;t match any route.
Definition: express.hpp:827
route_params_appender_t(route_params_appender_t &&)=delete
void http_delete(string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:701
generic_express_route_entry_t(Method_Matcher &&method_matcher, string_view_t route_path, actual_request_handler_t handler)
Definition: express.hpp:532
void http_post(string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:773
void http_delete(string_view_t route_path, actual_request_handler_t handler)
Definition: express.hpp:690
route_params_t(const route_params_t &)=delete
void http_post(string_view_t route_path, actual_request_handler_t handler)
Definition: express.hpp:762
route_params_t::indexed_parameters_container_t & m_indexed_parameters
Definition: express.hpp:272
buffered_matcher_holder_t m_method_matcher
HTTP method to match.
Definition: express.hpp:408
void http_get(string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler)
Definition: express.hpp:725