github.com/NaverCloudPlatform/ncloud-sdk-go-v2@v1.6.13/services/server/api_response.go (about)

     1  /*
     2   * server
     3   *
     4   * <br/>https://ncloud.apigw.ntruss.com/server/v2
     5   *
     6   * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
     7   */
     8  
     9  package server
    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  }