aboutsummaryrefslogtreecommitdiff
path: root/example/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'example/main.go')
-rw-r--r--example/main.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/example/main.go b/example/main.go
index 9f25e61..d5d034e 100644
--- a/example/main.go
+++ b/example/main.go
@@ -12,10 +12,15 @@ import (
)
func main() {
- s := rpc.New()
-
- s.AddTransport(&transport.HTTP{Bind: ":8000"})
- s.AddTransport(&transport.TCP{Bind: ":3000"})
+ s := rpc.New(
+ rpc.WithLogger(rpc.StdLogger),
+ rpc.WithTransport(&transport.HTTP{Bind: ":8000", CORSOrigin: "*"}),
+ )
+ // Set options after constructor
+ s.Use(
+ rpc.WithTransport(&transport.TCP{Bind: ":3000"}),
+ rpc.WithMiddleware(rpc.LoggerMiddleware(rpc.StdLogger)),
+ )
s.Register("multiply", rpc.H(Multiply))
s.Register("divide", rpc.H(Divide))