@@ -666,9 +666,20 @@ impl Request {
666
666
Ok ( ( ) )
667
667
}
668
668
669
- /// Create a GET request.
669
+ /// Create a `GET` request.
670
+ ///
671
+ /// The `GET` method requests a representation of the specified resource.
672
+ /// Requests using `GET` should only retrieve data.
670
673
///
671
674
/// # Examples
675
+ ///
676
+ /// ```
677
+ /// use http_types::{Method, Request, Url};
678
+ ///
679
+ /// let mut req = Request::get(Url::parse("https://example.com").unwrap());
680
+ /// req.set_body("Hello, Nori!");
681
+ /// assert_eq!(req.method(), Method::Get);
682
+ /// ```
672
683
pub fn get < U > ( url : U ) -> Self
673
684
where
674
685
U : TryInto < Url > ,
@@ -677,9 +688,19 @@ impl Request {
677
688
Request :: new ( Method :: Get , url)
678
689
}
679
690
680
- /// Create a HEAD request.
691
+ /// Create a `HEAD` request.
692
+ ///
693
+ /// The `HEAD` method asks for a response identical to that of a `GET`
694
+ /// request, but without the response body.
681
695
///
682
696
/// # Examples
697
+ ///
698
+ /// ```
699
+ /// use http_types::{Method, Request, Url};
700
+ ///
701
+ /// let mut req = Request::head(Url::parse("https://example.com").unwrap());
702
+ /// assert_eq!(req.method(), Method::Head);
703
+ /// ```
683
704
pub fn head < U > ( url : U ) -> Self
684
705
where
685
706
U : TryInto < Url > ,
@@ -688,9 +709,19 @@ impl Request {
688
709
Request :: new ( Method :: Head , url)
689
710
}
690
711
691
- /// Create a POST request.
712
+ /// Create a `POST` request.
713
+ ///
714
+ /// The `POST` method is used to submit an entity to the specified resource,
715
+ /// often causing a change in state or side effects on the server.
692
716
///
693
717
/// # Examples
718
+ ///
719
+ /// ```
720
+ /// use http_types::{Method, Request, Url};
721
+ ///
722
+ /// let mut req = Request::post(Url::parse("https://example.com").unwrap());
723
+ /// assert_eq!(req.method(), Method::Post);
724
+ /// ```
694
725
pub fn post < U > ( url : U ) -> Self
695
726
where
696
727
U : TryInto < Url > ,
@@ -699,9 +730,19 @@ impl Request {
699
730
Request :: new ( Method :: Post , url)
700
731
}
701
732
702
- /// Create a PUT request.
733
+ /// Create a `PUT` request.
734
+ ///
735
+ /// The `PUT` method replaces all current representations of the target
736
+ /// resource with the request payload.
703
737
///
704
738
/// # Examples
739
+ ///
740
+ /// ```
741
+ /// use http_types::{Method, Request, Url};
742
+ ///
743
+ /// let mut req = Request::put(Url::parse("https://example.com").unwrap());
744
+ /// assert_eq!(req.method(), Method::Put);
745
+ /// ```
705
746
pub fn put < U > ( url : U ) -> Self
706
747
where
707
748
U : TryInto < Url > ,
@@ -710,9 +751,18 @@ impl Request {
710
751
Request :: new ( Method :: Put , url)
711
752
}
712
753
713
- /// Create a DELETE request.
754
+ /// Create a `DELETE` request.
755
+ ///
756
+ /// The `DELETE` method deletes the specified resource.
714
757
///
715
758
/// # Examples
759
+ ///
760
+ /// ```
761
+ /// use http_types::{Method, Request, Url};
762
+ ///
763
+ /// let mut req = Request::delete(Url::parse("https://example.com").unwrap());
764
+ /// assert_eq!(req.method(), Method::Delete);
765
+ /// ```
716
766
pub fn delete < U > ( url : U ) -> Self
717
767
where
718
768
U : TryInto < Url > ,
@@ -721,9 +771,19 @@ impl Request {
721
771
Request :: new ( Method :: Delete , url)
722
772
}
723
773
724
- /// Create a CONNECT request.
774
+ /// Create a `CONNECT` request.
775
+ ///
776
+ /// The `CONNECT` method establishes a tunnel to the server identified by
777
+ /// the target resource.
725
778
///
726
779
/// # Examples
780
+ ///
781
+ /// ```
782
+ /// use http_types::{Method, Request, Url};
783
+ ///
784
+ /// let mut req = Request::connect(Url::parse("https://example.com").unwrap());
785
+ /// assert_eq!(req.method(), Method::Connect);
786
+ /// ```
727
787
pub fn connect < U > ( url : U ) -> Self
728
788
where
729
789
U : TryInto < Url > ,
@@ -732,20 +792,40 @@ impl Request {
732
792
Request :: new ( Method :: Connect , url)
733
793
}
734
794
735
- /// Create a OPTIONS request.
795
+ /// Create a `OPTIONS` request.
796
+ ///
797
+ /// The `OPTIONS` method is used to describe the communication options for
798
+ /// the target resource.
736
799
///
737
800
/// # Examples
738
- pub fn optiond < U > ( url : U ) -> Self
801
+ ///
802
+ /// ```
803
+ /// use http_types::{Method, Request, Url};
804
+ ///
805
+ /// let mut req = Request::options(Url::parse("https://example.com").unwrap());
806
+ /// assert_eq!(req.method(), Method::Options);
807
+ /// ```
808
+ pub fn options < U > ( url : U ) -> Self
739
809
where
740
810
U : TryInto < Url > ,
741
811
U :: Error : std:: fmt:: Debug ,
742
812
{
743
813
Request :: new ( Method :: Options , url)
744
814
}
745
815
746
- /// Create a TRACE request.
816
+ /// Create a `TRACE` request.
817
+ ///
818
+ /// The `TRACE` method performs a message loop-back test along the path to
819
+ /// the target resource.
747
820
///
748
821
/// # Examples
822
+ ///
823
+ /// ```
824
+ /// use http_types::{Method, Request, Url};
825
+ ///
826
+ /// let mut req = Request::trace(Url::parse("https://example.com").unwrap());
827
+ /// assert_eq!(req.method(), Method::Trace);
828
+ /// ```
749
829
pub fn trace < U > ( url : U ) -> Self
750
830
where
751
831
U : TryInto < Url > ,
@@ -754,9 +834,18 @@ impl Request {
754
834
Request :: new ( Method :: Trace , url)
755
835
}
756
836
757
- /// Create a PATCH request.
837
+ /// Create a `PATCH` request.
838
+ ///
839
+ /// The `PATCH` method is used to apply partial modifications to a resource.
758
840
///
759
841
/// # Examples
842
+ ///
843
+ /// ```
844
+ /// use http_types::{Method, Request, Url};
845
+ ///
846
+ /// let mut req = Request::patch(Url::parse("https://example.com").unwrap());
847
+ /// assert_eq!(req.method(), Method::Patch);
848
+ /// ```
760
849
pub fn patch < U > ( url : U ) -> Self
761
850
where
762
851
U : TryInto < Url > ,
0 commit comments