File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,23 @@ pub struct FormBody {
77}
88
99impl FormBody {
10+ /// Creates a new form.
11+ pub fn new ( ) -> Self {
12+ Self { fields : Vec :: new ( ) }
13+ }
14+
1015 /// Creates an empty form.
1116 pub fn empty ( ) -> Self {
1217 Self :: default ( )
1318 }
1419
1520 /// Adds a field to the form.
16- pub fn add_field ( & mut self , name : impl Into < String > , value : impl Into < String > ) {
17- self . fields . push ( ( name. into ( ) , value. into ( ) ) ) ;
21+ pub fn field ( self , name : impl Into < String > , value : impl Into < String > ) -> Self {
22+ let mut fields = self . fields ;
23+
24+ fields. push ( ( name. into ( ) , value. into ( ) ) ) ;
25+
26+ Self { fields }
1827 }
1928
2029 /// Converts the form body to a URL-encoded string.
Original file line number Diff line number Diff line change 11#![ doc = include_str ! ( "../README.md" ) ]
22pub mod body;
3+ pub mod form;
34mod headers;
45pub use headers:: Headers ;
56pub mod matchers;
@@ -18,6 +19,7 @@ pub use status::{Code, StatusCode};
1819pub mod prelude {
1920 pub use crate :: {
2021 body:: Body ,
22+ form:: FormBody ,
2123 headers:: Headers ,
2224 matchers:: * ,
2325 mock:: Mock ,
@@ -30,7 +32,6 @@ pub mod prelude {
3032}
3133mod ext;
3234mod service;
33- mod form;
3435
3536/// Represents errors that can occur while serving mocks.
3637#[ derive( thiserror:: Error , Debug ) ]
Original file line number Diff line number Diff line change @@ -67,8 +67,8 @@ impl When {
6767 }
6868
6969 /// Form Body.
70- pub fn form ( self , body : FormBody ) -> Self {
71- self . push ( matchers:: form ( body ) ) ;
70+ pub fn form ( self , form_body : FormBody ) -> Self {
71+ self . push ( matchers:: form ( form_body ) ) ;
7272 self
7373 }
7474
You can’t perform that action at this time.
0 commit comments