Skip to content

Commit 935879c

Browse files
committed
godoc update
1 parent 1f58ca6 commit 935879c

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

request.go

+33-24
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
type (
2424
// Request is extends `http.Request` for aah framework
2525
Request struct {
26-
// Schema value is protocol info; it's a derived value in the order as below.
26+
// Scheme value is protocol; it's a derived value in the order as below.
2727
// - `X-Forwarded-Proto` is not empty return value as is
2828
// - `http.Request.TLS` is not nil value is `https`
2929
// - `http.Request.TLS` is nil value is `http`
@@ -41,24 +41,26 @@ type (
4141
// Header request HTTP headers
4242
Header http.Header
4343

44-
// Payload holds the value from HTTP request for `Content-Type`
45-
// JSON and XML.
46-
Payload []byte
47-
48-
// ContentType the parsed HTTP header `Content-Type`.
44+
// ContentType the parsed value of HTTP header `Content-Type`.
45+
// Partial implementation as per RFC1521.
4946
ContentType *ContentType
5047

5148
// AcceptContentType negotiated value from HTTP Header `Accept`.
5249
// The resolve order is-
5350
// 1) URL extension
54-
// 2) Accept header.
51+
// 2) Accept header (As per RFC7231 and vendor type as per RFC4288)
5552
// Most quailfied one based on quality factor otherwise default is HTML.
5653
AcceptContentType *ContentType
5754

5855
// AcceptEncoding negotiated value from HTTP Header the `Accept-Encoding`
56+
// As per RFC7231.
5957
// Most quailfied one based on quality factor.
6058
AcceptEncoding *AcceptSpec
6159

60+
// Payload holds the value from HTTP request for `Content-Type`
61+
// JSON and XML.
62+
Payload []byte
63+
6264
// Params contains values from Path, Query, Form and File.
6365
Params *Params
6466

@@ -68,10 +70,12 @@ type (
6870
// UserAgent value of the HTTP 'User-Agent' header.
6971
UserAgent string
7072

71-
// ClientIP remote client IP address.
73+
// ClientIP remote client IP address aka Remote IP. Parsed in the order of
74+
// `X-Forwarded-For`, `X-Real-IP` and finally `http.Request.RemoteAddr`.
7275
ClientIP string
7376

7477
// Locale negotiated value from HTTP Header `Accept-Language`.
78+
// As per RFC7231.
7579
Locale *Locale
7680

7781
// IsGzipAccepted is true if the HTTP client accepts Gzip response,
@@ -131,7 +135,8 @@ func (r *Request) Cookies() []*http.Cookie {
131135
return r.Raw.Cookies()
132136
}
133137

134-
// IsJSONP method returns true if request query string has "callback=function_name".
138+
// IsJSONP method returns true if request URL query string has "callback=function_name".
139+
// otherwise false.
135140
func (r *Request) IsJSONP() bool {
136141
return !ess.IsStrEmpty(r.QueryValue(jsonpReqParamKey))
137142
}
@@ -142,29 +147,31 @@ func (r *Request) IsAJAX() bool {
142147
return r.Header.Get(HeaderXRequestedWith) == ajaxHeaderValue
143148
}
144149

145-
// PathValue method return value for given Path param key otherwise empty string.
150+
// PathValue method returns value for given Path param key otherwise empty string.
151+
// For eg.: /users/:userId => PathValue("userId")
146152
func (r *Request) PathValue(key string) string {
147153
return r.Params.PathValue(key)
148154
}
149155

150-
// QueryValue method return value for given query (aka URL) param key
156+
// QueryValue method returns value for given URL query param key
151157
// otherwise empty string.
152158
func (r *Request) QueryValue(key string) string {
153159
return r.Params.QueryValue(key)
154160
}
155161

156-
// QueryArrayValue method return array value for given query (aka URL)
157-
// param key otherwise empty string.
162+
// QueryArrayValue method returns array value for given URL query param key
163+
// otherwise empty string slice.
158164
func (r *Request) QueryArrayValue(key string) []string {
159165
return r.Params.QueryArrayValue(key)
160166
}
161167

162-
// FormValue methos returns value for given form key otherwise empty string.
168+
// FormValue method returns value for given form key otherwise empty string.
163169
func (r *Request) FormValue(key string) string {
164170
return r.Params.FormValue(key)
165171
}
166172

167-
// FormArrayValue methos returns value for given form key otherwise empty string.
173+
// FormArrayValue method returns array value for given form key
174+
// otherwise empty string slice.
168175
func (r *Request) FormArrayValue(key string) []string {
169176
return r.Params.FormArrayValue(key)
170177
}
@@ -182,10 +189,10 @@ func (r *Request) Reset() {
182189
r.Method = ""
183190
r.Path = ""
184191
r.Header = nil
185-
r.Payload = nil
186192
r.ContentType = nil
187193
r.AcceptContentType = nil
188194
r.AcceptEncoding = nil
195+
r.Payload = nil
189196
r.Params = nil
190197
r.Referer = ""
191198
r.UserAgent = ""
@@ -199,7 +206,8 @@ func (r *Request) Reset() {
199206
// Params methods
200207
//___________________________________
201208

202-
// PathValue method return value for given Path param key otherwise empty string.
209+
// PathValue method returns value for given Path param key otherwise empty string.
210+
// For eg.: `/users/:userId` => `PathValue("userId")`.
203211
func (p *Params) PathValue(key string) string {
204212
if p.Path != nil {
205213
if value, found := p.Path[key]; found {
@@ -209,30 +217,31 @@ func (p *Params) PathValue(key string) string {
209217
return ""
210218
}
211219

212-
// QueryValue method return value for given query (aka URL) param key
220+
// QueryValue method returns value for given URL query param key
213221
// otherwise empty string.
214222
func (p *Params) QueryValue(key string) string {
215223
return p.Query.Get(key)
216224
}
217225

218-
// QueryArrayValue method return array value for given query (aka URL)
219-
// param key otherwise empty string.
226+
// QueryArrayValue method returns array value for given URL query param key
227+
// otherwise empty string slice.
220228
func (p *Params) QueryArrayValue(key string) []string {
221229
if values, found := p.Query[key]; found {
222230
return values
223231
}
224232
return []string{}
225233
}
226234

227-
// FormValue methos returns value for given form key otherwise empty string.
235+
// FormValue method returns value for given form key otherwise empty string.
228236
func (p *Params) FormValue(key string) string {
229237
if p.Form != nil {
230238
return p.Form.Get(key)
231239
}
232240
return ""
233241
}
234242

235-
// FormArrayValue methos returns value for given form key otherwise empty string.
243+
// FormArrayValue method returns array value for given form key
244+
// otherwise empty string slice.
236245
func (p *Params) FormArrayValue(key string) []string {
237246
if p.Form != nil {
238247
if values, found := p.Form[key]; found {
@@ -242,8 +251,8 @@ func (p *Params) FormArrayValue(key string) []string {
242251
return []string{}
243252
}
244253

245-
// FormFile method returns the first file for the provided form key otherwise
246-
// returns error. It is caller responsibility to close the file.
254+
// FormFile method returns the first file for the provided form key
255+
// otherwise returns error. It is caller responsibility to close the file.
247256
func (p *Params) FormFile(key string) (multipart.File, *multipart.FileHeader, error) {
248257
if p.File != nil {
249258
if fh := p.File[key]; len(fh) > 0 {

0 commit comments

Comments
 (0)