Skip to content

Commit 7d272f1

Browse files
authored
style: fix minor issues (#40)
1 parent 82148b5 commit 7d272f1

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

group.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,7 @@ func (g *Group) Trace(path string, handler HandlerFunc, middlewares ...Middlewar
8484
//
8585
// Specifying middlewares is optional. Middlewares will only be applied to this route.
8686
func (g *Group) Any(path string, handler HandlerFunc, middlewares ...MiddlewareFunc) {
87-
methods := []string{
88-
http.MethodGet, http.MethodPost, http.MethodPut,
89-
http.MethodPatch, http.MethodDelete, http.MethodHead,
90-
http.MethodOptions, http.MethodConnect, http.MethodTrace,
91-
}
92-
g.Add(path, handler, methods, middlewares...)
87+
g.Add(path, handler, allMethods, middlewares...)
9388
}
9489

9590
// Add adds a route to the group routes.

html_renderer/html.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import (
1313
)
1414

1515
var (
16-
// Default root directory.
16+
// DefaultRootDir is the default root directory.
1717
DefaultRootDir = filepath.FromSlash("templates/")
1818

19-
// Default layout directory. Relative to root directory.
19+
// DefaultLayoutsDir is the default layout directory. Relative to root directory.
2020
DefaultLayoutsDir = filepath.FromSlash("layouts/")
2121

22-
// Default template file extensions.
22+
// DefaultExtension is the default template file extension.
2323
DefaultExtension = ".html"
2424

2525
// ErrTemplateNotFound is the internal error when template is not found.

kid.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ type (
4747
// Version of Kid.
4848
const Version string = "0.1.0"
4949

50+
// allMethods is all of the HTTP methods.
51+
var allMethods = []string{
52+
http.MethodGet, http.MethodPost, http.MethodPut,
53+
http.MethodPatch, http.MethodDelete, http.MethodHead,
54+
http.MethodOptions, http.MethodConnect, http.MethodTrace,
55+
}
56+
5057
// New returns a new instance of Kid.
5158
func New() *Kid {
5259
kid := Kid{
@@ -155,12 +162,7 @@ func (k *Kid) Trace(path string, handler HandlerFunc, middlewares ...MiddlewareF
155162
//
156163
// Specifying middlewares is optional. Middlewares will only be applied to this route.
157164
func (k *Kid) Any(path string, handler HandlerFunc, middlewares ...MiddlewareFunc) {
158-
methods := []string{
159-
http.MethodGet, http.MethodPost, http.MethodPut,
160-
http.MethodPatch, http.MethodDelete, http.MethodHead,
161-
http.MethodOptions, http.MethodConnect, http.MethodTrace,
162-
}
163-
k.router.add(path, handler, methods, middlewares)
165+
k.router.add(path, handler, allMethods, middlewares)
164166
}
165167

166168
// Group creates a new router group.

0 commit comments

Comments
 (0)