github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/apiguard/tykgen/response.go (about)

     1  /*
     2   * Tyk Gateway API
     3   *
     4   * The Tyk Gateway API is the primary means for integrating your application with the Tyk API Gateway system. This API is very small, and has no granular permissions system. It is intended to be used purely for internal automation and integration.  **Warning: Under no circumstances should outside parties be granted access to this API.**  The Tyk Gateway API is capable of:  * Managing session objects (key generation) * Managing and listing policies * Managing and listing API Definitions (only when not using the Dashboard) * Hot reloads / reloading a cluster configuration * OAuth client creation (only when not using the Dashboard)   In order to use the Gateway API, you'll need to set the `secret` parameter in your tyk.conf file.  The shared secret you set should then be sent along as a header with each Gateway API Request in order for it to be successful:  ``` x-tyk-authorization: <your-secret> ``` <br/> <b>The Tyk Gateway API is subsumed by the Tyk Dashboard API in Pro installations.</b>
     5   *
     6   * API version: 5.5.0
     7   * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
     8   */
     9  package swagger
    10  
    11  import (
    12  	"net/http"
    13  )
    14  
    15  type APIResponse struct {
    16  	*http.Response `json:"-"`
    17  	Message        string `json:"message,omitempty"`
    18  	// Operation is the name of the swagger operation.
    19  	Operation string `json:"operation,omitempty"`
    20  	// RequestURL is the request URL. This value is always available, even if the
    21  	// embedded *http.Response is nil.
    22  	RequestURL string `json:"url,omitempty"`
    23  	// Method is the HTTP method used for the request.  This value is always
    24  	// available, even if the embedded *http.Response is nil.
    25  	Method string `json:"method,omitempty"`
    26  	// Payload holds the contents of the response body (which may be nil or empty).
    27  	// This is provided here as the raw response.Body() reader will have already
    28  	// been drained.
    29  	Payload []byte `json:"-"`
    30  }
    31  
    32  func NewAPIResponse(r *http.Response) *APIResponse {
    33  
    34  	response := &APIResponse{Response: r}
    35  	return response
    36  }
    37  
    38  func NewAPIResponseWithError(errorMessage string) *APIResponse {
    39  
    40  	response := &APIResponse{Message: errorMessage}
    41  	return response
    42  }