...

Source file src/github.com/ory/fosite/response_handler.go

Documentation: github.com/ory/fosite

     1  package fosite
     2  
     3  import "net/http"
     4  
     5  // ResponseModeHandler provides a contract for handling custom response modes
     6  type ResponseModeHandler interface {
     7  	// ResponseModes returns a set of supported response modes handled
     8  	// by the interface implementation.
     9  	//
    10  	// In an authorize request with any of the provide response modes
    11  	// methods `WriteAuthorizeResponse` and `WriteAuthorizeError` will be
    12  	// invoked to write the successful or error authorization responses respectively.
    13  	ResponseModes() ResponseModeTypes
    14  
    15  	// WriteAuthorizeResponse writes successful responses
    16  	//
    17  	// Following headers are expected to be set by default:
    18  	// header.Set("Cache-Control", "no-store")
    19  	// header.Set("Pragma", "no-cache")
    20  	WriteAuthorizeResponse(rw http.ResponseWriter, ar AuthorizeRequester, resp AuthorizeResponder)
    21  
    22  	// WriteAuthorizeError writes error responses
    23  	//
    24  	// Following headers are expected to be set by default:
    25  	// header.Set("Cache-Control", "no-store")
    26  	// header.Set("Pragma", "no-cache")
    27  	WriteAuthorizeError(rw http.ResponseWriter, ar AuthorizeRequester, err error)
    28  }
    29  
    30  type ResponseModeTypes []ResponseModeType
    31  
    32  func (rs ResponseModeTypes) Has(item ResponseModeType) bool {
    33  	for _, r := range rs {
    34  		if r == item {
    35  			return true
    36  		}
    37  	}
    38  	return false
    39  }
    40  
    41  type DefaultResponseModeHandler struct{}
    42  
    43  func (d *DefaultResponseModeHandler) ResponseModes() ResponseModeTypes { return nil }
    44  func (d *DefaultResponseModeHandler) WriteAuthorizeResponse(rw http.ResponseWriter, ar AuthorizeRequester, resp AuthorizeResponder) {
    45  }
    46  func (d *DefaultResponseModeHandler) WriteAuthorizeError(rw http.ResponseWriter, ar AuthorizeRequester, err error) {
    47  }
    48  

View as plain text