msgs

package
v0.0.0-...-0356a80 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValidMethods

func GetValidMethods() []string

GetValidMethods returns allowed superset of the HTTP methods

func ValidateMethod

func ValidateMethod(method string) error

ValidateMethod validates that the methods is in the the right set

Types

type IBinding

type IBinding interface {
	Bind(req *http.Request, obj interface{}) error
}

IBinding for all repositories

type JSONBinding

type JSONBinding struct{}

JSONBinding that reprents the access to the underlying database

func NewBinding

func NewBinding() *JSONBinding

NewBinding creates the binder of the correct type

func (*JSONBinding) Bind

func (binding *JSONBinding) Bind(req *http.Request, obj interface{}) error

Bind reads the data from request

type Request

type Request struct {
	Method  string
	Headers map[string][]string
	Body    map[string]interface{}
}

Request generically represents inputs to the service

func NewRequest

func NewRequest(method string, headers map[string][]string) (*Request, error)

NewRequest Creates a new generic request

func (*Request) Translate

func (request *Request) Translate(entity interface{}) error

Translate maps request body to the domain model

type Response

type Response struct {
	Headers map[string]string
	Code    int         `json:"code"`
	Body    interface{} `json:"body,omitempty"`
}

Response generically represents outputs from the service

func NewJSONResponse

func NewJSONResponse() *Response

NewJSONResponse creates a new response

func (*Response) HasBody

func (response *Response) HasBody() bool

HasBody indicates if the response has a body

func (*Response) IsValid

func (response *Response) IsValid() bool

IsValid indicates if the body is validate

func (*Response) ToBytes

func (response *Response) ToBytes() []byte

ToBytes object to byte array

Jump to

Keyboard shortcuts

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