Documentation
¶
Index ¶
- func BuildHttpURL(https bool, ip string, port int, uri string) string
- func DoHttpRequestJSON(ctx context.Context, httpClient *http.Client, url string, httpMethod string, ...) (error, int)
- func ReceiveJSONFromHttp(_ http.ResponseWriter, req *http.Request, jsonToFill interface{}) error
- func ToJSONBuffer(jsonToEncode interface{}) *bytes.Buffer
- func ToJSONBytes(jsonToEncode interface{}) []byte
- type AppHandler
- type CreateOfferMsg
- type GetOffersMsg
- type LaunchContainerMsg
- type NeighborOffersMsg
- type OfferRemoveMsg
- type RefreshOfferMsg
- type RefreshOfferResponseMsg
- type StopLocalContainerMsg
- type UpdateOfferMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildHttpURL ¶
Build a valid HTTP/HTTPS URL and returns it as a string.
func DoHttpRequestJSON ¶
func DoHttpRequestJSON(ctx context.Context, httpClient *http.Client, url string, httpMethod string, jsonToSend interface{}, jsonToGet interface{}) (error, int)
Build and execute an HTTP Request and frees all the resources getting all the data before.
func ReceiveJSONFromHttp ¶
func ReceiveJSONFromHttp(_ http.ResponseWriter, req *http.Request, jsonToFill interface{}) error
Validate the HTTP message content extracting the JSON into a Go structure if necessary.
func ToJSONBuffer ¶
Encodes a golang struct into a buffer using JSON format.
func ToJSONBytes ¶
func ToJSONBytes(jsonToEncode interface{}) []byte
Encodes a golang struct into a an array of bytes.
Types ¶
type AppHandler ¶
type AppHandler func(http.ResponseWriter, *http.Request) (interface{}, error)
HTTP Generic handler for all of HTTP endpoints
func (AppHandler) ServeHTTP ¶
func (fn AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP generalizes an HTTP handler, handling generic logic to write responses and treat errors.
type CreateOfferMsg ¶
type CreateOfferMsg struct { ToNode types.Node `json:"TN"` FromNode types.Node `json:"FN"` Offer types.Offer `json:"O"` }
Create offer struct/JSON used in REST APIs when a supplier offer resources to be used by others.
type GetOffersMsg ¶
type GetOffersMsg struct { FromNode types.Node `json:"FN"` ToTrader types.Node `json:"TT"` Relay bool `json:"R"` }
Get offers struct/JSON used in the REST APIs.
type LaunchContainerMsg ¶
type LaunchContainerMsg struct { FromBuyer types.Node `json:"FB"` Offer types.Offer `json:"O"` ContainersConfigs []types.ContainerConfig `json:"CC"` }
Launch container struct/JSON used in the REST APIs.
type NeighborOffersMsg ¶
type NeighborOffersMsg struct { FromNeighbor types.Node `json:"FN"` ToNeighbor types.Node `json:"TN"` NeighborOffering types.Node `json:"NO"` }
Neighbor offer's message struct/JSON used in the REST APIs.
type OfferRemoveMsg ¶
type OfferRemoveMsg struct { FromSupplier types.Node `json:"FS"` ToTrader types.Node `json:"TT"` Offer types.Offer `json:"O"` }
Remove offer struct/JSON used in remote REST APIs when a supplier remove its offer from a trader.
type RefreshOfferMsg ¶
Refresh offer struct/JSON used in remote REST APIs when a trader refresh an offer.
type RefreshOfferResponseMsg ¶
type RefreshOfferResponseMsg struct {
Refreshed bool `json:"R"` // True if the offer was refreshed succeeded and false otherwise
}
Response to a refresh offer message used in remote REST APIs when a supplier acknowledges the refresh message
type StopLocalContainerMsg ¶
type StopLocalContainerMsg struct {
ContainerID string `json:"CId"`
}
Stop container struct/JSON used in the REST APIs