github.com/hyperledger/aries-framework-go@v0.3.2/pkg/didcomm/protocol/issuecredential/middleware.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package issuecredential
     8  
     9  import "github.com/hyperledger/aries-framework-go/pkg/didcomm/common/service"
    10  
    11  // Handler describes middleware interface.
    12  type Handler interface {
    13  	Handle(metadata Metadata) error
    14  }
    15  
    16  // Middleware function receives next handler and returns handler that needs to be executed.
    17  type Middleware func(next Handler) Handler
    18  
    19  // HandlerFunc is a helper type which implements the middleware Handler interface.
    20  type HandlerFunc func(metadata Metadata) error
    21  
    22  // Handle implements function to satisfy the Handler interface.
    23  func (hf HandlerFunc) Handle(metadata Metadata) error {
    24  	return hf(metadata)
    25  }
    26  
    27  // Metadata provides helpful information for the processing.
    28  type Metadata interface {
    29  	// Message contains the original inbound/outbound message
    30  	Message() service.DIDCommMsg
    31  	// OfferCredentialV2 is pointer to the message provided by the user through the Continue function.
    32  	OfferCredentialV2() *OfferCredentialV2
    33  	// ProposeCredentialV2 is pointer to the message provided by the user through the Continue function.
    34  	ProposeCredentialV2() *ProposeCredentialV2
    35  	// IssueCredential is pointer to the message provided by the user through the Continue function.
    36  	IssueCredentialV2() *IssueCredentialV2
    37  	// RequestCredential is pointer to message provided by the user through the Continue function.
    38  	RequestCredentialV2() *RequestCredentialV2
    39  	// CredentialNames is a slice which contains credential names provided by the user through the Continue function.
    40  	CredentialNames() []string
    41  	// StateName provides the state name
    42  	StateName() string
    43  	// Properties provides the possibility to set properties
    44  	Properties() map[string]interface{}
    45  }