Skip to content

Commit c5bc6ae

Browse files
committed
Merge branch 'develop' of github.com:revel/revel into develop
2 parents 6f10624 + 813c964 commit c5bc6ae

File tree

7 files changed

+52
-49
lines changed

7 files changed

+52
-49
lines changed

cache/memcached.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/revel/revel"
99
)
1010

11-
// Wraps the Memcached client to meet the Cache interface.
11+
// MemcachedCache wraps the Memcached client to meet the Cache interface.
1212
type MemcachedCache struct {
1313
*memcache.Client
1414
defaultExpiration time.Duration
@@ -87,7 +87,7 @@ func (c MemcachedCache) invoke(f func(*memcache.Client, *memcache.Item) error,
8787
}))
8888
}
8989

90-
// Implement a Getter on top of the returned item map.
90+
// ItemMapGetter implements a Getter on top of the returned item map.
9191
type ItemMapGetter map[string]*memcache.Item
9292

9393
func (g ItemMapGetter) Get(key string, ptrValue interface{}) error {

cache/redis.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
"github.com/revel/revel"
88
)
99

10-
// Wraps the Redis client to meet the Cache interface.
10+
// RedisCache wraps the Redis client to meet the Cache interface.
1111
type RedisCache struct {
1212
pool *redis.Pool
1313
defaultExpiration time.Duration
1414
}
1515

16+
// NewRedisCache returns a new RedisCache with given parameters
1617
// until redigo supports sharding/clustering, only one host will be in hostList
1718
func NewRedisCache(host string, password string, defaultExpiration time.Duration) RedisCache {
1819
var pool = &redis.Pool{
@@ -253,7 +254,7 @@ func (c RedisCache) invoke(f func(string, ...interface{}) (interface{}, error),
253254
return err
254255
}
255256

256-
// Implement a Getter on top of the returned item map.
257+
// RedisItemMapGetter implements a Getter on top of the returned item map.
257258
type RedisItemMapGetter map[string][]byte
258259

259260
func (g RedisItemMapGetter) Get(key string, ptrValue interface{}) error {

controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ func (c *Controller) Redirect(val interface{}, args ...interface{}) Result {
258258
return &RedirectToActionResult{val}
259259
}
260260

261-
// Perform a message lookup for the given message name using the given arguments
262-
// using the current language defined for this controller.
261+
// Message performs a lookup for the given message name using the given
262+
// arguments using the current language defined for this controller.
263263
//
264264
// The current language is set by the i18n plugin.
265265
func (c *Controller) Message(message string, args ...interface{}) (value string) {

intercept.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"reflect"
66
)
77

8-
// An "interceptor" is functionality invoked by the framework BEFORE or AFTER
8+
// An InterceptorFunc is functionality invoked by the framework BEFORE or AFTER
99
// an action.
1010
//
1111
// An interceptor may optionally return a Result (instead of nil). Depending on

skeleton/app/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func init() {
2525
// revel.OnAppStart(FillCache)
2626
}
2727

28+
// HeaderFilter adds common security headers
2829
// TODO turn this into revel.HeaderFilter
2930
// should probably also have a filter for CSRF
3031
// not sure if it can go in the same filter or not
3132
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
32-
// Add some common security headers
3333
c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
3434
c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
3535
c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")

template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var invalidSlugPattern = regexp.MustCompile(`[^a-z0-9 _-]`)
4444
var whiteSpacePattern = regexp.MustCompile(`\s+`)
4545

4646
var (
47-
// The functions available for use in the templates.
47+
// TemplateFuncs is the collection of functions available in templates
4848
TemplateFuncs = map[string]interface{}{
4949
"url": ReverseURL,
5050
"set": func(renderArgs map[string]interface{}, key string, value interface{}) template.JS {

testing/testsuite.go

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ func (t *TestSuite) NewTestRequest(req *http.Request) *TestRequest {
6363
}
6464
}
6565

66-
// Return the address and port of the server, e.g. "127.0.0.1:8557"
66+
// Host returns the address and port of the server, e.g. "127.0.0.1:8557"
6767
func (t *TestSuite) Host() string {
6868
if revel.Server.Addr[0] == ':' {
6969
return "127.0.0.1" + revel.Server.Addr
7070
}
7171
return revel.Server.Addr
7272
}
7373

74-
// Return the base http/https URL of the server, e.g. "http://127.0.0.1:8557".
74+
// BaseUrl returns the base http/https URL of the server, e.g. "http://127.0.0.1:8557".
7575
// The scheme is set to https if http.ssl is set to true in the configuration file.
7676
func (t *TestSuite) BaseUrl() string {
7777
if revel.HTTPSsl {
@@ -80,18 +80,18 @@ func (t *TestSuite) BaseUrl() string {
8080
return "http://" + t.Host()
8181
}
8282

83-
// Return the base websocket URL of the server, e.g. "ws://127.0.0.1:8557"
83+
// WebSocketUrl returns the base websocket URL of the server, e.g. "ws://127.0.0.1:8557"
8484
func (t *TestSuite) WebSocketUrl() string {
8585
return "ws://" + t.Host()
8686
}
8787

88-
// Issue a GET request to the given path and store the result in Response and
89-
// ResponseBody.
88+
// Get issues a GET request to the given path and stores the result in Response
89+
// and ResponseBody.
9090
func (t *TestSuite) Get(path string) {
9191
t.GetCustom(t.BaseUrl() + path).Send()
9292
}
9393

94-
// Return a GET request to the given uri in a form of its wrapper.
94+
// GetCustom returns a GET request to the given URI in a form of its wrapper.
9595
func (t *TestSuite) GetCustom(uri string) *TestRequest {
9696
req, err := http.NewRequest("GET", uri, nil)
9797
if err != nil {
@@ -100,13 +100,14 @@ func (t *TestSuite) GetCustom(uri string) *TestRequest {
100100
return t.NewTestRequest(req)
101101
}
102102

103-
// Issue a DELETE request to the given path and store the result in Response and
104-
// ResponseBody.
103+
// Delete issues a DELETE request to the given path and stores the result in
104+
// Response and ResponseBody.
105105
func (t *TestSuite) Delete(path string) {
106106
t.DeleteCustom(t.BaseUrl() + path).Send()
107107
}
108108

109-
// Return a DELETE request to the given uri in a form of its wrapper.
109+
// DeleteCustom returns a DELETE request to the given URI in a form of its
110+
// wrapper.
110111
func (t *TestSuite) DeleteCustom(uri string) *TestRequest {
111112
req, err := http.NewRequest("DELETE", uri, nil)
112113
if err != nil {
@@ -115,14 +116,14 @@ func (t *TestSuite) DeleteCustom(uri string) *TestRequest {
115116
return t.NewTestRequest(req)
116117
}
117118

118-
// Issue a PUT request to the given path, sending the given Content-Type and
119-
// data, and store the result in Response and ResponseBody. "data" may be nil.
119+
// Put issues a PUT request to the given path, sending the given Content-Type
120+
// and data, storing the result in Response and ResponseBody. "data" may be nil.
120121
func (t *TestSuite) Put(path string, contentType string, reader io.Reader) {
121122
t.PutCustom(t.BaseUrl()+path, contentType, reader).Send()
122123
}
123124

124-
// Return a PUT request to the given uri with specified Content-Type and data
125-
// in a form of wrapper. "data" may be nil.
125+
// PutCustom returns a PUT request to the given URI with specified Content-Type
126+
// and data in a form of wrapper. "data" may be nil.
126127
func (t *TestSuite) PutCustom(uri string, contentType string, reader io.Reader) *TestRequest {
127128
req, err := http.NewRequest("PUT", uri, reader)
128129
if err != nil {
@@ -132,26 +133,27 @@ func (t *TestSuite) PutCustom(uri string, contentType string, reader io.Reader)
132133
return t.NewTestRequest(req)
133134
}
134135

135-
// Issue a PUT request to the given path as a form put of the given key and
136-
// values, and store the result in Response and ResponseBody.
136+
// PutForm issues a PUT request to the given path as a form put of the given key
137+
// and values, and stores the result in Response and ResponseBody.
137138
func (t *TestSuite) PutForm(path string, data url.Values) {
138139
t.PutFormCustom(t.BaseUrl()+path, data).Send()
139140
}
140141

141-
// Return a PUT request to the given uri as a form put of the given key and values.
142-
// The request is in a form of TestRequest wrapper.
142+
// PutFormCustom returns a PUT request to the given URI as a form put of the
143+
// given key and values. The request is in a form of TestRequest wrapper.
143144
func (t *TestSuite) PutFormCustom(uri string, data url.Values) *TestRequest {
144145
return t.PutCustom(uri, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
145146
}
146147

147-
// Issue a PATCH request to the given path, sending the given Content-Type and
148-
// data, and store the result in Response and ResponseBody. "data" may be nil.
148+
// Patch issues a PATCH request to the given path, sending the given
149+
// Content-Type and data, and stores the result in Response and ResponseBody.
150+
// "data" may be nil.
149151
func (t *TestSuite) Patch(path string, contentType string, reader io.Reader) {
150152
t.PatchCustom(t.BaseUrl()+path, contentType, reader).Send()
151153
}
152154

153-
// Return a PATCH request to the given uri with specified Content-Type and data
154-
// in a form of wrapper. "data" may be nil.
155+
// PatchCustom returns a PATCH request to the given URI with specified
156+
// Content-Type and data in a form of wrapper. "data" may be nil.
155157
func (t *TestSuite) PatchCustom(uri string, contentType string, reader io.Reader) *TestRequest {
156158
req, err := http.NewRequest("PATCH", uri, reader)
157159
if err != nil {
@@ -161,14 +163,14 @@ func (t *TestSuite) PatchCustom(uri string, contentType string, reader io.Reader
161163
return t.NewTestRequest(req)
162164
}
163165

164-
// Issue a POST request to the given path, sending the given Content-Type and
165-
// data, and store the result in Response and ResponseBody. "data" may be nil.
166+
// Post issues a POST request to the given path, sending the given Content-Type
167+
// and data, storing the result in Response and ResponseBody. "data" may be nil.
166168
func (t *TestSuite) Post(path string, contentType string, reader io.Reader) {
167169
t.PostCustom(t.BaseUrl()+path, contentType, reader).Send()
168170
}
169171

170-
// Return a POST request to the given uri with specified Content-Type and data
171-
// in a form of wrapper. "data" may be nil.
172+
// PostCustom returns a POST request to the given URI with specified
173+
// Content-Type and data in a form of wrapper. "data" may be nil.
172174
func (t *TestSuite) PostCustom(uri string, contentType string, reader io.Reader) *TestRequest {
173175
req, err := http.NewRequest("POST", uri, reader)
174176
if err != nil {
@@ -178,26 +180,26 @@ func (t *TestSuite) PostCustom(uri string, contentType string, reader io.Reader)
178180
return t.NewTestRequest(req)
179181
}
180182

181-
// Issue a POST request to the given path as a form post of the given key and
182-
// values, and store the result in Response and ResponseBody.
183+
// PostForm issues a POST request to the given path as a form post of the given
184+
// key and values, and stores the result in Response and ResponseBody.
183185
func (t *TestSuite) PostForm(path string, data url.Values) {
184186
t.PostFormCustom(t.BaseUrl()+path, data).Send()
185187
}
186188

187-
// Return a POST request to the given uri as a form post of the given key and values.
188-
// The request is in a form of TestRequest wrapper.
189+
// PostFormCustom returns a POST request to the given URI as a form post of the
190+
// given key and values. The request is in a form of TestRequest wrapper.
189191
func (t *TestSuite) PostFormCustom(uri string, data url.Values) *TestRequest {
190192
return t.PostCustom(uri, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
191193
}
192194

193-
// Issue a multipart request to the given path sending given params and files,
194-
// and store the result in Response and ResponseBody.
195+
// PostFile issues a multipart request to the given path sending given params
196+
// and files, and stores the result in Response and ResponseBody.
195197
func (t *TestSuite) PostFile(path string, params url.Values, filePaths url.Values) {
196198
t.PostFileCustom(t.BaseUrl()+path, params, filePaths).Send()
197199
}
198200

199-
// Return a multipart request to the given uri in a form of its wrapper
200-
// with the given params and files.
201+
// PostFileCustom returns a multipart request to the given URI in a form of its
202+
// wrapper with the given params and files.
201203
func (t *TestSuite) PostFileCustom(uri string, params url.Values, filePaths url.Values) *TestRequest {
202204
body := &bytes.Buffer{}
203205
writer := multipart.NewWriter(body)
@@ -220,16 +222,16 @@ func (t *TestSuite) PostFileCustom(uri string, params url.Values, filePaths url.
220222
return t.PostCustom(uri, writer.FormDataContentType(), body)
221223
}
222224

223-
// Issue any request and read the response. If successful, the caller may
225+
// Send issues any request and reads the response. If successful, the caller may
224226
// examine the Response and ResponseBody properties. Session data will be
225227
// added to the request cookies for you.
226228
func (r *TestRequest) Send() {
227229
r.AddCookie(r.testSuite.Session.Cookie())
228230
r.MakeRequest()
229231
}
230232

231-
// Issue any request and read the response. If successful, the caller may
232-
// examine the Response and ResponseBody properties. You will need to
233+
// MakeRequest issues any request and read the response. If successful, the
234+
// caller may examine the Response and ResponseBody properties. You will need to
233235
// manage session / cookie data manually
234236
func (r *TestRequest) MakeRequest() {
235237
var err error
@@ -250,7 +252,7 @@ func (r *TestRequest) MakeRequest() {
250252
}
251253
}
252254

253-
// Create a websocket connection to the given path and return the connection
255+
// WebSocket creates a websocket connection to the given path and returns it
254256
func (t *TestSuite) WebSocket(path string) *websocket.Conn {
255257
origin := t.BaseUrl() + "/"
256258
url := t.WebSocketUrl() + path
@@ -308,21 +310,21 @@ func (t *TestSuite) Assertf(exp bool, formatStr string, args ...interface{}) {
308310
}
309311
}
310312

311-
// Assert that the response contains the given string.
313+
// AssertContains asserts that the response contains the given string.
312314
func (t *TestSuite) AssertContains(s string) {
313315
if !bytes.Contains(t.ResponseBody, []byte(s)) {
314316
panic(fmt.Errorf("Assertion failed. Expected response to contain %s", s))
315317
}
316318
}
317319

318-
// Assert that the response does not contain the given string.
320+
// AssertNotContains asserts that the response does not contain the given string.
319321
func (t *TestSuite) AssertNotContains(s string) {
320322
if bytes.Contains(t.ResponseBody, []byte(s)) {
321323
panic(fmt.Errorf("Assertion failed. Expected response not to contain %s", s))
322324
}
323325
}
324326

325-
// Assert that the response matches the given regular expression.
327+
// AssertContainsRegex asserts that the response matches the given regular expression.
326328
func (t *TestSuite) AssertContainsRegex(regex string) {
327329
r := regexp.MustCompile(regex)
328330

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy