ignoreCase
Dynamically ignoring the case of path
Usage
import "github.com/andeya/erpc/v7/plugin/ignorecase"
Test
package ignorecase_test
import (
"testing"
"time"
"github.com/andeya/erpc/v7"
"github.com/andeya/erpc/v7/plugin/ignorecase"
)
type Home struct {
erpc.CallCtx
}
func (h *Home) Test(arg *map[string]string) (map[string]interface{}, *erpc.Status) {
h.Session().Push("/push/test", map[string]string{
"your_id": string(h.PeekMeta("peer_id")),
})
return map[string]interface{}{
"arg": *arg,
}, nil
}
func TestIngoreCase(t *testing.T) {
// Server
srv := erpc.NewPeer(erpc.PeerConfig{ListenPort: 9090}, ignorecase.NewIgnoreCase())
srv.RouteCall(new(Home))
go srv.ListenAndServe()
time.Sleep(1e9)
// Client
cli := erpc.NewPeer(erpc.PeerConfig{}, ignorecase.NewIgnoreCase())
cli.RoutePush(new(Push))
sess, stat := cli.Dial(":9090")
if !stat.OK() {
t.Fatal(stat)
}
var result interface{}
stat = sess.Call("/home/TesT",
map[string]string{
"author": "andeya",
},
&result,
erpc.WithAddMeta("peer_id", "110"),
).Status()
if !stat.OK() {
t.Error(stat)
}
t.Logf("result:%v", result)
time.Sleep(3e9)
}
type Push struct {
erpc.PushCtx
}
func (p *Push) Test(arg *map[string]string) *erpc.Status {
erpc.Infof("receive push(%s):\narg: %#v\n", p.IP(), arg)
return nil
}
test command:
go test -v -run=TestIngoreCase