service

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 8 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 {
	Kind          Kind
	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)
	Direct        func(req Req) (interface{}, error)
	Auth          func(Req) error
	After         func(Config, Req)
}

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 ContextTPL added in v0.1.14

type ContextTPL interface {
	Result(Req) (interface{}, error)
}

type Kind added in v0.1.14

type Kind int
const (
	DEFAULT Kind = iota // 0
	DIRECT              // 1, and so on.
)

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
}

func (ParamItem) AsInt added in v0.3.18

func (p ParamItem) AsInt() int

func (ParamItem) SetValue added in v0.3.11

func (p ParamItem) SetValue(value string)

func (*ParamItem) SetValues added in v0.3.11

func (p *ParamItem) SetValues(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)

func (RawParams) GetWithFallback added in v0.3.18

func (ps RawParams) GetWithFallback(name string, fallback string) ParamItem

type Req added in v0.1.14

type Req struct {
	ID      meta.RequestId
	Headers RawHeaders
	Body    RawBody
	Params  RawParams
	Timer   *servertiming.Header
	Context *gin.Context
}

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