util

package
v0.0.0-...-38a8f93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHttpURL

func BuildHttpURL(https bool, ip string, port int, uri string) string

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

func ToJSONBuffer(jsonToEncode interface{}) *bytes.Buffer

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

type RefreshOfferMsg struct {
	FromTrader types.Node  `json:"FT"`
	Offer      types.Offer `json:"O"`
}

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

type UpdateOfferMsg

type UpdateOfferMsg struct {
	FromSupplier types.Node  `json:"FS"`
	ToTrader     types.Node  `json:"TT"`
	Offer        types.Offer `json:"O"`
}

UpdateOfferMsg offer struct/JSON used in remote REST APIs when a supplier wants to update its offer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL