protocols

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: Apache-2.0, BSD-2-Clause-Views, MIT Imports: 12 Imported by: 0

Documentation

Overview

Package protocols contains message structures used to implement protocols.

Index

Constants

This section is empty.

Variables

View Source
var (
	// InternalServerError is an error response
	InternalServerError = &ErrorResponse{Code: "internal_server_error", Message: "Internal Server Error, please try again.", Status: http.StatusInternalServerError}
	// InvalidParameterError  is an error response
	InvalidParameterError = &ErrorResponse{Code: "invalid_parameter", Message: "Invalid parameter.", Status: http.StatusBadRequest}
	// MissingParameterError is an error response
	MissingParameterError = &ErrorResponse{Code: "missing_parameter", Message: "Required parameter is missing.", Status: http.StatusBadRequest}
)

Functions

func IsValidAccountID

func IsValidAccountID(accountID string) bool

IsValidAccountID returns true if account ID is valid

func IsValidAmount

func IsValidAmount(a string) bool

IsValidAmount returns true if amount is valid

func IsValidAssetCode

func IsValidAssetCode(code string) bool

IsValidAssetCode returns true if asset code is valid

func IsValidSecret added in v0.0.23

func IsValidSecret(secret string) bool

IsValidSecret returns true if secret is valid

Types

type Asset

type Asset struct {
	Code   string `name:"asset_code" json:"code"`
	Issuer string `name:"asset_issuer" json:"issuer"`
}

Asset represents native or credit asset

func (Asset) String

func (a Asset) String() string

String returns string representation of this asset

func (Asset) ToBaseAsset

func (a Asset) ToBaseAsset() build.Asset

ToBaseAsset transforms Asset to github.com/stellar/go-stellar-base/build.Asset

func (Asset) Validate

func (a Asset) Validate() bool

Validate checks if asset params are correct.

type ErrorResponse

type ErrorResponse struct {
	// HTTP status code
	Status int `json:"-"`
	// Error status code
	Code string `json:"code"`
	// Error message that will be returned to API consumer
	Message string `json:"message"`
	// Additional information returned to API consumer
	MoreInfo string `json:"more_info,omitempty"`
	// Error data that will be returned to API consumer
	Data map[string]interface{} `json:"data,omitempty"`
	// Error message that will be logged.
	LogMessage string `json:"-"`
	// Error data that will be logged.
	LogData map[string]interface{} `json:"-"`
}

ErrorResponse represents error response and implements server.Response and error interfaces

func NewInternalServerError

func NewInternalServerError(logMessage string, logData map[string]interface{}) *ErrorResponse

NewInternalServerError creates and returns a new InternalServerError

func NewInvalidParameterError

func NewInvalidParameterError(name, value, moreInfo string, additionalLogData ...map[string]interface{}) *ErrorResponse

NewInvalidParameterError creates and returns a new InvalidParameterError

func NewMissingParameter

func NewMissingParameter(name string) *ErrorResponse

NewMissingParameter creates and returns a new MissingParameterError

func (*ErrorResponse) Error

func (error *ErrorResponse) Error() string

Error returns Message or LogMessage if set

func (*ErrorResponse) HTTPStatus

func (error *ErrorResponse) HTTPStatus() int

HTTPStatus returns ErrorResponse.Status

func (*ErrorResponse) Marshal

func (error *ErrorResponse) Marshal() []byte

Marshal marshals ErrorResponse

type FormRequest

type FormRequest struct {
	HTTPRequest *http.Request
}

FormRequest allows transforming http.Request url.Values from/to request structs

func (*FormRequest) CheckRequired

func (request *FormRequest) CheckRequired(destination interface{}) error

CheckRequired checks whether all fields marked as required have value

func (*FormRequest) FromRequest

func (request *FormRequest) FromRequest(r *http.Request, destination interface{}) error

FromRequest transforms http.Request to request struct object

func (*FormRequest) ToValues

func (request *FormRequest) ToValues(object interface{}) (values url.Values)

ToValues transforms request object to url.Values

type ForwardDestination added in v0.0.30

type ForwardDestination struct {
	Domain string     `name:"domain"`
	Fields url.Values `name:"fields"`
}

ForwardDestination contains fields required to create forward federation request

type SuccessResponse

type SuccessResponse struct{}

SuccessResponse is embedded in all success responses and implements server.Response interface

func (*SuccessResponse) HTTPStatus

func (response *SuccessResponse) HTTPStatus() int

HTTPStatus returns http.StatusOK

Directories

Path Synopsis
Package compliance contains message structures required to implement compliance protocol.
Package compliance contains message structures required to implement compliance protocol.

Jump to

Keyboard shortcuts

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