forked from andeya/erpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ignorecase.go
36 lines (28 loc) · 823 Bytes
/
ignorecase.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
// Package ignorecase dynamically ignoring the case of path
package ignorecase
import (
"strings"
tp "github.com/henrylee2cn/teleport"
)
// NewIgnoreCase Returns a ignoreCase plugin.
func NewIgnoreCase() *ignoreCase {
return &ignoreCase{}
}
type ignoreCase struct{}
var (
_ tp.PostReadCallHeaderPlugin = new(ignoreCase)
_ tp.PostReadPushHeaderPlugin = new(ignoreCase)
)
func (i *ignoreCase) Name() string {
return "ignoreCase"
}
func (i *ignoreCase) PostReadCallHeader(ctx tp.ReadCtx) *tp.Rerror {
// Dynamic transformation path is lowercase
ctx.ResetServiceMethod(strings.ToLower(ctx.ServiceMethod()))
return nil
}
func (i *ignoreCase) PostReadPushHeader(ctx tp.ReadCtx) *tp.Rerror {
// Dynamic transformation path is lowercase
ctx.ResetServiceMethod(strings.ToLower(ctx.ServiceMethod()))
return nil
}