-
Notifications
You must be signed in to change notification settings - Fork 66
/
slash.go
50 lines (39 loc) · 1.05 KB
/
slash.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package plugin
import (
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
type (
AddTrailingSlash struct {
Base `json:",squash"`
middleware.TrailingSlashConfig `json:",squash"`
}
RemoveTrailingSlash struct {
Base `json:",squash"`
middleware.TrailingSlashConfig `json:",squash"`
}
)
func (s *AddTrailingSlash) Initialize() (err error) {
s.Middleware = middleware.AddTrailingSlashWithConfig(s.TrailingSlashConfig)
return
}
func (*AddTrailingSlash) Priority() int {
return -1
}
func (s *AddTrailingSlash) Process(next echo.HandlerFunc) echo.HandlerFunc {
return s.Middleware(next)
}
func (*AddTrailingSlash) Terminate() {
}
func (s *RemoveTrailingSlash) Initialize() (err error) {
s.Middleware = middleware.RemoveTrailingSlashWithConfig(s.TrailingSlashConfig)
return
}
func (*RemoveTrailingSlash) Priority() int {
return -1
}
func (s *RemoveTrailingSlash) Process(next echo.HandlerFunc) echo.HandlerFunc {
return s.Middleware(next)
}
func (*RemoveTrailingSlash) Terminate() {
}