@@ -42,7 +42,7 @@ func NewRequest() *RequestBuilder {
4242 }
4343}
4444
45- // This structure caches request settings as we build up the request.
45+ // RequestBuilder caches request settings as we build up the request.
4646type RequestBuilder struct {
4747 Method string
4848 Path string
@@ -52,7 +52,7 @@ type RequestBuilder struct {
5252 Cookies []* http.Cookie
5353}
5454
55- // Path operations
55+ // WithMethod sets the method and path
5656func (r * RequestBuilder ) WithMethod (method string , path string ) * RequestBuilder {
5757 r .Method = method
5858 r .Path = path
@@ -79,7 +79,7 @@ func (r *RequestBuilder) Delete(path string) *RequestBuilder {
7979 return r .WithMethod ("DELETE" , path )
8080}
8181
82- // Header operations
82+ // WithHeader sets a header
8383func (r * RequestBuilder ) WithHeader (header , value string ) * RequestBuilder {
8484 r .Headers [header ] = value
8585 return r
@@ -117,7 +117,7 @@ func (r *RequestBuilder) WithBody(body []byte) *RequestBuilder {
117117 return r
118118}
119119
120- // This function takes an object as input, marshals it to JSON, and sends it
120+ // WithJsonBody takes an object as input, marshals it to JSON, and sends it
121121// as the body with Content-Type: application/json
122122func (r * RequestBuilder ) WithJsonBody (obj interface {}) * RequestBuilder {
123123 var err error
@@ -128,7 +128,7 @@ func (r *RequestBuilder) WithJsonBody(obj interface{}) *RequestBuilder {
128128 return r .WithJsonContentType ()
129129}
130130
131- // Cookie operations
131+ // WithCookie sets a cookie
132132func (r * RequestBuilder ) WithCookie (c * http.Cookie ) * RequestBuilder {
133133 r .Cookies = append (r .Cookies , c )
134134 return r
@@ -176,7 +176,7 @@ func (r *RequestBuilder) Go(t *testing.T, e *echo.Echo) *CompletedRequest {
176176 return r .GoWithHTTPHandler (t , e )
177177}
178178
179- // This is the result of calling Go() on the request builder. We're wrapping the
179+ // CompletedRequest is the result of calling Go() on the request builder. We're wrapping the
180180// ResponseRecorder with some nice helper functions.
181181type CompletedRequest struct {
182182 Recorder * httptest.ResponseRecorder
@@ -190,7 +190,7 @@ func (c *CompletedRequest) DisallowUnknownFields() {
190190 c .Strict = true
191191}
192192
193- // This function takes a destination object as input, and unmarshals the object
193+ // UnmarshalBodyToObject takes a destination object as input, and unmarshals the object
194194// in the response based on the Content-Type header.
195195func (c * CompletedRequest ) UnmarshalBodyToObject (obj interface {}) error {
196196 ctype := c .Recorder .Header ().Get ("Content-Type" )
@@ -206,13 +206,13 @@ func (c *CompletedRequest) UnmarshalBodyToObject(obj interface{}) error {
206206 return handler (ctype , c .Recorder .Body , obj , c .Strict )
207207}
208208
209- // This function assumes that the response contains JSON and unmarshals it
209+ // UnmarshalJsonToObject assumes that the response contains JSON and unmarshals it
210210// into the specified object.
211211func (c * CompletedRequest ) UnmarshalJsonToObject (obj interface {}) error {
212212 return json .Unmarshal (c .Recorder .Body .Bytes (), obj )
213213}
214214
215- // Shortcut for response code
215+ // Code is a shortcut for response code
216216func (c * CompletedRequest ) Code () int {
217217 return c .Recorder .Code
218218}
0 commit comments