service

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBody

func ParseBody(data []byte, destination interface{}) error

Types

type Collection

type Collection []Config

type Config

type Config struct {
	IsStream      bool
	IsPrivate     bool
	Key           string
	Path          string
	Method        string
	Build         func(meta.RequestId, RawHeaders, RawBody, RawParams) (TPL, error)
	BuildMessages func(meta.RequestId, RawHeaders, RawBody, RawParams) (MessageTPL, error)
}

type ContentResponse

type ContentResponse struct {
	Content interface{} `json:"content"`
	ContentResponseContext
	ContentResponseMeta
}

func ToContentResponse

func ToContentResponse(
	resources interface{},
	meta ContentResponseMeta,
) ContentResponse

type ContentResponseContext added in v0.1.7

type ContentResponseContext struct {
	First      bool `json:"first"`
	Last       bool `json:"last"`
	TotalPages int  `json:"total_pages"`
}

type ContentResponseMeta

type ContentResponseMeta struct {
	Size  int   `json:"size"`
	Total int   `json:"total"`
	Page  int   `json:"current_page"`
	Error error `json:"error,omitempty"`
}

type Message added in v0.1.2

type Message struct {
	Key   string
	Value interface{}
}

type MessageTPL added in v0.1.2

type MessageTPL interface {
	Result() (Messages, error)
}

type Messages added in v0.1.2

type Messages []Message

type ParamHolder added in v0.1.3

type ParamHolder interface {
	Get(string) (ParamItem, bool)
}

type ParamItem added in v0.1.3

type ParamItem struct {
	Key    string
	Value  string
	Values []string
}

type PrivateTPL added in v0.0.26

type PrivateTPL interface {
	Auth(meta.RequestId, RawHeaders, RawBody, RawParams) error
	TPL
}

type RawBody

type RawBody []byte

type RawHeaders added in v0.0.26

type RawHeaders []ParamItem

func (RawHeaders) Assign added in v0.1.3

func (ps RawHeaders) Assign(v interface{}) error

func (RawHeaders) Get added in v0.0.26

func (ps RawHeaders) Get(name string) (ParamItem, bool)

type RawParams

type RawParams []ParamItem

func (RawParams) Assign added in v0.1.3

func (ps RawParams) Assign(v interface{}) error

func (RawParams) Get

func (ps RawParams) Get(name string) (ParamItem, bool)

type ResultError

type ResultError struct {
	Status     int                      `json:"-"`
	Field      string                   `json:"-"`
	ErrMessage string                   `json:"-"`
	Message    string                   `json:"message"`
	Reasons    []map[string]interface{} `json:"reasons"`
}

func ToResultError

func ToResultError(err error, message string, status int) *ResultError

func (*ResultError) Error

func (m *ResultError) Error() string

func (*ResultError) GetDetails

func (m *ResultError) GetDetails() ResultError

func (*ResultError) GetMessage

func (m *ResultError) GetMessage() string

func (*ResultError) GetStatus

func (m *ResultError) GetStatus() int

type StreamResult added in v0.0.56

type StreamResult struct {
	Type   string
	Length string
	Writer func(io.Writer) bool
}

type TPL

type TPL interface {
	Result() (interface{}, error)
}

Jump to

Keyboard shortcuts

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