Documentation ¶
Index ¶
- func BytesToInt64(bytes []byte) int64
- func Int64ToBytes(num int64, byteCount int) []byte
- func NewTemporaryFile(size int64, r io.Reader) (IReadCloserLen, IErrorArgs)
- func ReadRequestStream(r io.Reader) (*RequestStream, IErrorArgs)
- type Command
- type Error
- type Executer
- type Field
- type FieldList
- type IApplication
- type IApplicationStream
- type ICommand
- type IErrorArgs
- func ErrorFiled(field, message string) IErrorArgs
- func ErrorMessage(name, text string) IErrorArgs
- func Fields(obj any, files RequestFiles, names ...any) (json.Map, IErrorArgs)
- func NewError(name string, args json.Map) IErrorArgs
- func ReadBuf(r io.Reader, size int, field string) ([]byte, IErrorArgs)
- func ReadBufSize(r io.Reader, lenSize int, field string) ([]byte, IErrorArgs)
- func ReadByte(r io.Reader, field string, result *byte) IErrorArgs
- func ReadInt64(r io.Reader, size int, field string, result *int64) IErrorArgs
- func ReadString(r io.Reader, lenSize int, field string, result *string) IErrorArgs
- func Serialize(from json.Map, to any) IErrorArgs
- func WriteBuf(w io.Writer, buf []byte, field string) IErrorArgs
- func WriteBufSize(w io.Writer, val []byte, lenSize int, field string) IErrorArgs
- func WriteByte(w io.Writer, val byte, field string) IErrorArgs
- func WriteInt64(w io.Writer, val int64, size int, field string) IErrorArgs
- func WriteString(w io.Writer, val, field string, lenSize int) IErrorArgs
- type IExecuter
- type IFielderPost
- type IOwner
- type IReadCloser
- type IReadCloserLen
- type IRequest
- type IRequestIn
- type IRequestOut
- type IRestConverter
- type IRestFielder
- type IServer
- type IStream
- type IValidator
- type Request
- func (s *Request) Fields(obj any, files RequestFiles) (json.Map, IErrorArgs)
- func (s *Request) RClose()
- func (s *Request) RCommand() string
- func (s *Request) RData() json.Map
- func (s *Request) RFile(name string) (IReadCloserLen, bool)
- func (s *Request) RFiles() RequestFiles
- func (s *Request) RType() RequestType
- type RequestFiles
- type RequestIn
- func (s *RequestIn) Auth() json.Map
- func (s *RequestIn) ClientData(key string) (any, bool)
- func (s *RequestIn) GenerateToken(data json.Map, expire int64) (string, error)
- func (s *RequestIn) RCore() any
- func (s *RequestIn) ROwner() IOwner
- func (s *RequestIn) SetAuth(auth json.Map)
- func (s *RequestIn) SetClientData(key string, data any)
- type RequestStream
- type RequestType
- type ResponseEmpty
- type Server
- func (s *Server) Addr() string
- func (s *Server) Close() error
- func (s *Server) Context() context.Context
- func (s *Server) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (s *Server) Listen(timeout time.Duration) (err error)
- func (s *Server) Secret() []byte
- func (s *Server) TokenGenerate(m json.Map, expire int64) (string, error)
- type TemporaryFile
- type Time
- type TokenGenerateMethod
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToInt64 ¶ added in v1.3.0
BytesToInt64 конвертирует срез байтов в int64
func Int64ToBytes ¶ added in v1.3.0
Int64ToBytes упаковывает int64 в срез байтов заданной длины
func NewTemporaryFile ¶ added in v1.3.0
func NewTemporaryFile(size int64, r io.Reader) (IReadCloserLen, IErrorArgs)
func ReadRequestStream ¶ added in v1.3.0
func ReadRequestStream(r io.Reader) (*RequestStream, IErrorArgs)
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
func NewCommand ¶
func NewCommand(validator IValidator, executer IExecuter) *Command
func (*Command) Execute ¶
func (s *Command) Execute(r IRequestIn) IRequestOut
func (*Command) Validate ¶
func (s *Command) Validate(r IRequestIn) IRequestOut
type Executer ¶
type Executer struct {
// contains filtered or unexported fields
}
func NewExecuter ¶
func NewExecuter(method func(r IRequestIn) IRequestOut) *Executer
func (*Executer) Execute ¶
func (s *Executer) Execute(r IRequestIn) IRequestOut
type IApplication ¶ added in v1.1.0
type IApplication interface {
Executer(r IRequestIn) (IExecuter, bool)
}
type IApplicationStream ¶ added in v1.3.0
type IApplicationStream interface { IApplication Connect() chan<- IStream }
type ICommand ¶
type ICommand interface { IValidator IExecuter }
type IErrorArgs ¶
func ErrorFiled ¶ added in v1.1.0
func ErrorFiled(field, message string) IErrorArgs
func ErrorMessage ¶ added in v1.2.0
func ErrorMessage(name, text string) IErrorArgs
func Fields ¶ added in v1.1.0
func Fields(obj any, files RequestFiles, names ...any) (json.Map, IErrorArgs)
Fields позволяет получить значения объекта в json
func ReadBufSize ¶ added in v1.3.0
func ReadString ¶ added in v1.3.0
func WriteBufSize ¶ added in v1.3.0
func WriteInt64 ¶ added in v1.3.0
func WriteString ¶ added in v1.3.0
func WriteString(w io.Writer, val, field string, lenSize int) IErrorArgs
type IExecuter ¶
type IExecuter interface {
Execute(r IRequestIn) IRequestOut
}
type IFielderPost ¶ added in v1.3.3
type IFielderPost interface {
RestFieldsPost(result json.Map, files map[string]IReadCloserLen, names FieldList)
}
IFielder реадизует интерфейс завершения формирования полей объекта в "ручном" режиме. RestFields будет вызван после завершения автматического формирования полей объекта result - массив с полями, сформированными автоматически, в него можно вносить правки files - глобальный массив файловых дескрипторов, который будет передан в ответе клиенту
type IReadCloser ¶ added in v1.3.0
type IReadCloser interface { io.ReadCloser Len() int64 }
type IReadCloserLen ¶ added in v1.3.0
type IReadCloserLen interface { io.ReadCloser Len() int64 }
func NewReadCloserLen ¶ added in v1.3.0
func NewReadCloserLen(rc io.ReadCloser, len int64) IReadCloserLen
type IRequest ¶ added in v1.2.0
type IRequest interface { RType() RequestType RCommand() string RData() json.Map RFiles() RequestFiles RFile(string) (IReadCloserLen, bool) RClose() Fields(any, RequestFiles) (json.Map, IErrorArgs) }
type IRequestIn ¶ added in v1.3.0
type IRequestIn interface { IRequest Auth() json.Map SetAuth(json.Map) GenerateToken(data json.Map, expire int64) (string, error) ROwner() IOwner RCore() any OutSuccess(data json.Map, files RequestFiles) IRequestOut OutError(err IErrorArgs) IRequestOut ClientData(key string) (any, bool) SetClientData(key string, data any) }
type IRequestOut ¶ added in v1.3.0
type IRequestOut interface { IRequest Write(io.Writer) IErrorArgs }
type IRestConverter ¶ added in v1.3.3
type IRestConverter interface {
RestFrom(any) IErrorArgs
}
type IRestFielder ¶ added in v1.3.3
type IRestFielder interface {
RestFields(fieldName string, names ...any) (any, IErrorArgs)
}
type IServer ¶ added in v1.3.0
type IValidator ¶
type IValidator interface {
Validate(r IRequestIn) IRequestOut
}
type Request ¶
type Request struct { Type RequestType Command string Data json.Map Files RequestFiles }
func (*Request) Fields ¶ added in v1.3.0
func (s *Request) Fields(obj any, files RequestFiles) (json.Map, IErrorArgs)
func (*Request) RFiles ¶ added in v1.3.0
func (s *Request) RFiles() RequestFiles
func (*Request) RType ¶ added in v1.3.0
func (s *Request) RType() RequestType
type RequestFiles ¶ added in v1.3.0
type RequestFiles map[string]IReadCloserLen
type RequestIn ¶ added in v1.3.0
type RequestIn struct { IRequest Owner IOwner Core any GeneratorToken TokenGenerateMethod }
func (*RequestIn) ClientData ¶ added in v1.3.0
func (*RequestIn) GenerateToken ¶ added in v1.3.0
func (*RequestIn) SetClientData ¶ added in v1.3.0
type RequestStream ¶ added in v1.3.0
func NewRequestStream ¶ added in v1.3.0
func NewRequestStream(timeout time.Time, req *Request) *RequestStream
func (*RequestStream) Write ¶ added in v1.3.0
func (s *RequestStream) Write(w io.Writer) IErrorArgs
type RequestType ¶ added in v1.3.0
type RequestType byte
const ( RequestTypeIn RequestType = iota RequestTypeOut RequestTypeEvent )
type ResponseEmpty ¶ added in v1.3.0
type ResponseEmpty struct{}
func (*ResponseEmpty) Close ¶ added in v1.3.0
func (s *ResponseEmpty) Close()
func (*ResponseEmpty) FileSet ¶ added in v1.3.0
func (s *ResponseEmpty) FileSet(name string, file IReadCloserLen)
func (*ResponseEmpty) IsError ¶ added in v1.3.0
func (s *ResponseEmpty) IsError() bool
func (*ResponseEmpty) KeySet ¶ added in v1.3.0
func (s *ResponseEmpty) KeySet(key string, val any)
func (*ResponseEmpty) Send ¶ added in v1.3.0
func (s *ResponseEmpty) Send(writer any) IErrorArgs
type Server ¶ added in v1.3.0
type Server struct {
// contains filtered or unexported fields
}
func (*Server) HandleFunc ¶ added in v1.3.0
type TemporaryFile ¶ added in v1.3.0
func (*TemporaryFile) Close ¶ added in v1.3.0
func (s *TemporaryFile) Close() error
func (*TemporaryFile) Len ¶ added in v1.3.0
func (s *TemporaryFile) Len() int64
type Time ¶ added in v1.3.3
Time используется для формирования объекта времени из формата UnixMilli, а так же выгрузки в этот формат в результирующем объекте
func (*Time) RestFields ¶ added in v1.3.3
func (s *Time) RestFields(fieldName string, names ...any) (any, IErrorArgs)
RestFields выгружает объект в результирующий объект в формат UnixMilli
func (*Time) RestFrom ¶ added in v1.3.3
func (s *Time) RestFrom(source any) (err IErrorArgs)
RestFrom формирует из поля типа int64 объект времени
type TokenGenerateMethod ¶ added in v1.3.0
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func NewValidator(method func(r IRequestIn) IRequestOut) *Validator
func (*Validator) Validate ¶
func (s *Validator) Validate(r IRequestIn) IRequestOut