github.com/hyperledger/aries-framework-go@v0.3.2/pkg/framework/aries/example_test.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package aries 8 9 import ( 10 "fmt" 11 12 "github.com/hyperledger/aries-framework-go/component/storageutil/mem" 13 "github.com/hyperledger/aries-framework-go/pkg/didcomm/transport" 14 ) 15 16 func Example() { 17 // create the framework with user options 18 framework, err := New( 19 WithInboundTransport(newMockInTransport()), 20 WithStoreProvider(mem.NewProvider()), 21 WithProtocolStateStoreProvider(mem.NewProvider()), 22 ) 23 if err != nil { 24 fmt.Println("failed to create framework") 25 } 26 27 // get the context from the framework 28 ctx, err := framework.Context() 29 if err != nil { 30 fmt.Println("failed to create framework context") 31 } 32 33 fmt.Println("context created successfully") 34 fmt.Println(ctx.ServiceEndpoint()) 35 36 // Output: 37 // context created successfully 38 // http://server 39 } 40 41 // mock inbound transport. 42 type mockInTransport struct{} 43 44 func newMockInTransport() *mockInTransport { 45 return &mockInTransport{} 46 } 47 48 func (c *mockInTransport) Start(prov transport.Provider) error { 49 return nil 50 } 51 52 func (c *mockInTransport) Stop() error { 53 return nil 54 } 55 56 func (c *mockInTransport) Endpoint() string { 57 return "http://server" 58 }