github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/contributed-templates/stratoscale/restapi/operations/store/inventory_get_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package store
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"net/http"
    10  
    11  	"github.com/go-openapi/runtime"
    12  )
    13  
    14  // InventoryGetOKCode is the HTTP code returned for type InventoryGetOK
    15  const InventoryGetOKCode int = 200
    16  
    17  /*
    18  InventoryGetOK successful operation
    19  
    20  swagger:response inventoryGetOK
    21  */
    22  type InventoryGetOK struct {
    23  
    24  	/*
    25  	  In: Body
    26  	*/
    27  	Payload map[string]int32 `json:"body,omitempty"`
    28  }
    29  
    30  // NewInventoryGetOK creates InventoryGetOK with default headers values
    31  func NewInventoryGetOK() *InventoryGetOK {
    32  
    33  	return &InventoryGetOK{}
    34  }
    35  
    36  // WithPayload adds the payload to the inventory get o k response
    37  func (o *InventoryGetOK) WithPayload(payload map[string]int32) *InventoryGetOK {
    38  	o.Payload = payload
    39  	return o
    40  }
    41  
    42  // SetPayload sets the payload to the inventory get o k response
    43  func (o *InventoryGetOK) SetPayload(payload map[string]int32) {
    44  	o.Payload = payload
    45  }
    46  
    47  // WriteResponse to the client
    48  func (o *InventoryGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    49  
    50  	rw.WriteHeader(200)
    51  	payload := o.Payload
    52  	if payload == nil {
    53  		// return empty map
    54  		payload = make(map[string]int32, 50)
    55  	}
    56  
    57  	if err := producer.Produce(rw, payload); err != nil {
    58  		panic(err) // let the recovery middleware deal with this
    59  	}
    60  }