@@ -665,10 +665,110 @@ impl Request {
665
665
self . url . set_query ( Some ( & query) ) ;
666
666
Ok ( ( ) )
667
667
}
668
+
669
+ /// Create a GET request.
670
+ ///
671
+ /// # Examples
672
+ pub fn get < U > ( url : U ) -> Self
673
+ where
674
+ U : TryInto < Url > ,
675
+ U :: Error : std:: fmt:: Debug ,
676
+ {
677
+ Request :: new ( Method :: Get , url)
678
+ }
679
+
680
+ /// Create a HEAD request.
681
+ ///
682
+ /// # Examples
683
+ pub fn head < U > ( url : U ) -> Self
684
+ where
685
+ U : TryInto < Url > ,
686
+ U :: Error : std:: fmt:: Debug ,
687
+ {
688
+ Request :: new ( Method :: Head , url)
689
+ }
690
+
691
+ /// Create a POST request.
692
+ ///
693
+ /// # Examples
694
+ pub fn post < U > ( url : U ) -> Self
695
+ where
696
+ U : TryInto < Url > ,
697
+ U :: Error : std:: fmt:: Debug ,
698
+ {
699
+ Request :: new ( Method :: Post , url)
700
+ }
701
+
702
+ /// Create a PUT request.
703
+ ///
704
+ /// # Examples
705
+ pub fn put < U > ( url : U ) -> Self
706
+ where
707
+ U : TryInto < Url > ,
708
+ U :: Error : std:: fmt:: Debug ,
709
+ {
710
+ Request :: new ( Method :: Put , url)
711
+ }
712
+
713
+ /// Create a DELETE request.
714
+ ///
715
+ /// # Examples
716
+ pub fn delete < U > ( url : U ) -> Self
717
+ where
718
+ U : TryInto < Url > ,
719
+ U :: Error : std:: fmt:: Debug ,
720
+ {
721
+ Request :: new ( Method :: Delete , url)
722
+ }
723
+
724
+ /// Create a CONNECT request.
725
+ ///
726
+ /// # Examples
727
+ pub fn connect < U > ( url : U ) -> Self
728
+ where
729
+ U : TryInto < Url > ,
730
+ U :: Error : std:: fmt:: Debug ,
731
+ {
732
+ Request :: new ( Method :: Connect , url)
733
+ }
734
+
735
+ /// Create a OPTIONS request.
736
+ ///
737
+ /// # Examples
738
+ pub fn optiond < U > ( url : U ) -> Self
739
+ where
740
+ U : TryInto < Url > ,
741
+ U :: Error : std:: fmt:: Debug ,
742
+ {
743
+ Request :: new ( Method :: Options , url)
744
+ }
745
+
746
+ /// Create a TRACE request.
747
+ ///
748
+ /// # Examples
749
+ pub fn trace < U > ( url : U ) -> Self
750
+ where
751
+ U : TryInto < Url > ,
752
+ U :: Error : std:: fmt:: Debug ,
753
+ {
754
+ Request :: new ( Method :: Trace , url)
755
+ }
756
+
757
+ /// Create a PATCH request.
758
+ ///
759
+ /// # Examples
760
+ pub fn patch < U > ( url : U ) -> Self
761
+ where
762
+ U : TryInto < Url > ,
763
+ U :: Error : std:: fmt:: Debug ,
764
+ {
765
+ Request :: new ( Method :: Patch , url)
766
+ }
668
767
}
669
768
670
769
impl Clone for Request {
671
- /// Clone the request, resolving the body to `Body::empty()` and removing extensions.
770
+ /// Clone the request, resolving the body to `Body::empty()` and removing
771
+ /// extensions.
672
772
fn clone ( & self ) -> Self {
673
773
Request {
674
774
method : self . method . clone ( ) ,
0 commit comments