From 4a81eff217c40c459c9a9ed4f318b4dd9bc5ee8a Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Sun, 22 May 2022 16:37:48 +0300 Subject: Middlewares and options --- example/main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'example/main.go') 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)) -- cgit v1.2.3