github.com/hyperledger/aries-framework-go@v0.3.2/pkg/framework/aries/defaults/defaults.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package defaults 8 9 import ( 10 "fmt" 11 12 "github.com/hyperledger/aries-framework-go/pkg/didcomm/transport/http" 13 "github.com/hyperledger/aries-framework-go/pkg/didcomm/transport/ws" 14 "github.com/hyperledger/aries-framework-go/pkg/framework/aries" 15 ) 16 17 // WithInboundHTTPAddr return new default http inbound transport. 18 func WithInboundHTTPAddr(internalAddr, externalAddr, certFile, keyFile string) aries.Option { 19 return func(opts *aries.Aries) error { 20 inbound, err := http.NewInbound(internalAddr, externalAddr, certFile, keyFile) 21 if err != nil { 22 return fmt.Errorf("http inbound transport initialization failed : %w", err) 23 } 24 25 return aries.WithInboundTransport(inbound)(opts) 26 } 27 } 28 29 // WithInboundWSAddr return new default ws inbound transport. If readLimit is 0, the default value of 32kB is set. 30 func WithInboundWSAddr(internalAddr, externalAddr, certFile, keyFile string, readLimit int64) aries.Option { 31 return func(opts *aries.Aries) error { 32 var inboundOpts []ws.InboundOpt 33 34 if readLimit > 0 { 35 inboundOpts = append(inboundOpts, ws.WithInboundReadLimit(readLimit)) 36 } 37 38 inbound, err := ws.NewInbound(internalAddr, externalAddr, certFile, keyFile, inboundOpts...) 39 if err != nil { 40 return fmt.Errorf("ws inbound transport initialization failed : %w", err) 41 } 42 43 return aries.WithInboundTransport(inbound)(opts) 44 } 45 }