Documentation
¶
Index ¶
- func AddServiceToServer(s Server, service Service) error
- func ConstructResourceEndpoint(ep ResourceEndpointI, resourceType string, op api.Operation)
- func FullRequestPath(r Request) string
- func FullRequestServicePath(r Request) string
- func InitKebabEndpoint(ep ResourceEndpointI, operationName string, ...)
- func InitResourceEndpoint(ep ResourceEndpointI, resourceType string, operationName string, ...)
- func MessageFromRequest[T any](request Request, init ...func(*T)) (*T, error)
- func ParseDbQuery(request Request, model interface{}, queryName string, cmd ...api.Query) (*db.Filter, error)
- func ParseValidateRequest[T any](request Request, init ...func(*T)) (*T, error)
- func ServiceName(service string, version string) string
- func SetResponseList(r Request, response api.ResponseListI, resourceType ...string)
- func UniqueFormData(request Request) map[string]string
- type AuthParameterGetter
- type AuthParameterSetter
- type CheckAccess
- type CheckAccessEndpoint
- type CheckAccessResourceEndpoint
- type CheckStatusEndpoint
- type DynamicFieldTranslator
- type DynamicTable
- type DynamicTableConfig
- type DynamicTableEndpoint
- type DynamicTableField
- type DynamicTableQuery
- type DynamicTables
- type DynamicTablesService
- type EchoEndpoint
- type Endpoint
- type EndpointBase
- func (e *EndpointBase) Construct(op api.Operation)
- func (e *EndpointBase) GetRequestPostprocessor() EndpointHandler
- func (e *EndpointBase) GetRequestPreprocessor() EndpointHandler
- func (e *EndpointBase) HandleRequest(request Request) error
- func (e *EndpointBase) Init(operationName string, accessType ...access_control.AccessType)
- func (e *EndpointBase) IsRequestPayloadNeeded() bool
- func (e *EndpointBase) NewRequestMessage() interface{}
- func (e *EndpointBase) Postprocess(request Request) error
- func (e *EndpointBase) PrecheckBeforeAuth(request Request, smsMessage *string, skipSms *bool) error
- func (e *EndpointBase) PreprocessBeforeAuth(request Request) error
- func (e *EndpointBase) SetMessageHandlers(handlers MessageHandlers)
- func (e *EndpointBase) SetRequestPostprocessor(handler EndpointHandler)
- func (e *EndpointBase) SetRequestPreprocessor(handler EndpointHandler)
- type EndpointHandler
- type EndpointNoHandler
- type EnumEntry
- type EnumGetter
- type FieldEnums
- type File
- type MessageBuilder
- type MessageContent
- type MessageConverter
- type MessageHandlers
- type MessageHandlersConfig
- type Request
- type RequestBase
- func (r *RequestBase) Endpoint() Endpoint
- func (r *RequestBase) GetSessionParameter(key string) string
- func (r *RequestBase) Init(app app_context.Context, log logger.Logger, db db.DB, fields ...logger.Fields)
- func (r *RequestBase) LoadSessionParameters(parameters map[string]string)
- func (r *RequestBase) Message() RequestMessage
- func (r *RequestBase) SetEndpoint(endpoint Endpoint)
- func (r *RequestBase) SetMessage(msg RequestMessage)
- func (r *RequestBase) SetSessionParameter(key string, value string)
- func (r *RequestBase) StoreSessionParameters() map[string]string
- type RequestMessage
- type RequestMessageBase
- func (m *RequestMessageBase) BinaryContent() []byte
- func (m *RequestMessageBase) LogicMessage() any
- func (m *RequestMessageBase) SetBinaryContent(content []byte)
- func (m *RequestMessageBase) SetLogicMessage(msg interface{})
- func (m *RequestMessageBase) SetTransportMessage(msg interface{})
- func (m *RequestMessageBase) TransportMessage() any
- type ResourceEndpoint
- type ResourceEndpointI
- type Response
- type ResponseBase
- func (r *ResponseBase) File() *File
- func (r *ResponseBase) Message() interface{}
- func (r *ResponseBase) Payload() []byte
- func (r *ResponseBase) RedirectPath() string
- func (r *ResponseBase) Request() Request
- func (r *ResponseBase) SetFile(file *File)
- func (r *ResponseBase) SetMessage(message api.Response)
- func (r *ResponseBase) SetPayload(data []byte)
- func (r *ResponseBase) SetRedirectPath(path string)
- func (r *ResponseBase) SetRequest(request Request)
- func (r *ResponseBase) SetStatusMessage(status string)
- func (r *ResponseBase) SetSuccessStatusMessage()
- type Server
- type ServerBase
- type ServerBaseConfig
- type Service
- type ServiceBase
- func (s *ServiceBase) AddDynamicTables(tables ...*DynamicTableConfig)
- func (s *ServiceBase) AttachToServer(server Server) error
- func (s *ServiceBase) DynamicTables() []*DynamicTableConfig
- func (s *ServiceBase) Init(pathName string, packageName string, multitenancy ...bool)
- func (s *ServiceBase) InitExplicit(pathName string, serviceName string, packageName string, multitenancy ...bool)
- func (s *ServiceBase) Package() string
- func (s *ServiceBase) Server() Server
- func (s *ServiceBase) SetEndpointMessageHandlers(handlers map[string]MessageHandlers)
- func (s *ServiceBase) SetPackage(value string)
- func (s *ServiceBase) SetSupportsMultitenancy(enable bool)
- func (s *ServiceBase) SupportsMultitenancy() bool
- type ServiceEachEndpointHandler
- type StatusResponse
- type StatusService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddServiceToServer ¶
func ConstructResourceEndpoint ¶
func ConstructResourceEndpoint(ep ResourceEndpointI, resourceType string, op api.Operation)
func FullRequestPath ¶
func FullRequestServicePath ¶
func InitKebabEndpoint ¶
func InitKebabEndpoint(ep ResourceEndpointI, operationName string, accessType ...access_control.AccessType)
func InitResourceEndpoint ¶
func InitResourceEndpoint(ep ResourceEndpointI, resourceType string, operationName string, accessType ...access_control.AccessType)
func MessageFromRequest ¶
func ParseDbQuery ¶
func ParseValidateRequest ¶
func ServiceName ¶
func SetResponseList ¶
func SetResponseList(r Request, response api.ResponseListI, resourceType ...string)
func UniqueFormData ¶
Types ¶
type AuthParameterGetter ¶
type AuthParameterSetter ¶
type CheckAccess ¶
type CheckAccess struct{}
func (*CheckAccess) HandleRequest ¶
func (e *CheckAccess) HandleRequest(request Request) error
type CheckAccessEndpoint ¶
type CheckAccessEndpoint struct {
EndpointBase
CheckAccess
}
func NewCheckAccessEndpoint ¶
func NewCheckAccessEndpoint(operationName string, accessType ...access_control.AccessType) *CheckAccessEndpoint
type CheckAccessResourceEndpoint ¶
type CheckAccessResourceEndpoint struct {
ResourceEndpoint
CheckAccess
}
func NewCheckAccessResourceEndpoint ¶
func NewCheckAccessResourceEndpoint(resource string, operationName string, accessType ...access_control.AccessType) *CheckAccessResourceEndpoint
type CheckStatusEndpoint ¶
type CheckStatusEndpoint struct {
ResourceEndpoint
}
func NewCheckStatusEndpoint ¶
func NewCheckStatusEndpoint() *CheckStatusEndpoint
func (*CheckStatusEndpoint) HandleRequest ¶
func (e *CheckStatusEndpoint) HandleRequest(request Request) error
type DynamicFieldTranslator ¶
type DynamicFieldTranslator interface {
Tr(field *DynamicTableField, tableName ...string) (string, bool)
}
type DynamicTable ¶
type DynamicTable struct {
api.ResponseStub
Columns []*DynamicTableField `json:"columns"`
DefaultSortColumn string `json:"default_sort_column"`
DefaultSortDirection string `json:"default_sort_direction"`
}
type DynamicTableConfig ¶
type DynamicTableEndpoint ¶
type DynamicTableEndpoint struct {
ResourceEndpoint
// contains filtered or unexported fields
}
func NewDynamicTableEndpoint ¶
func NewDynamicTableEndpoint(service *DynamicTablesService) *DynamicTableEndpoint
func (*DynamicTableEndpoint) HandleRequest ¶
func (e *DynamicTableEndpoint) HandleRequest(request Request) error
type DynamicTableField ¶
type DynamicTableQuery ¶
type DynamicTableQuery struct {
Path string `json:"path" validate:"required" vmessage:"Invalid table path."`
}
type DynamicTables ¶
type DynamicTables interface {
AddTable(table *DynamicTableConfig) error
Table(request Request, path string) (*DynamicTable, error)
SetTranslator(translator DynamicFieldTranslator)
}
type DynamicTablesService ¶
type DynamicTablesService struct {
ServiceBase
}
func NewDynamicTablesService ¶
func NewDynamicTablesService(multitenancy ...bool) *DynamicTablesService
type EchoEndpoint ¶
type EchoEndpoint struct {
EndpointBase
}
func NewEchoEndpoint ¶
func NewEchoEndpoint(opName ...string) *EchoEndpoint
func (*EchoEndpoint) HandleRequest ¶
func (e *EchoEndpoint) HandleRequest(request Request) error
func (*EchoEndpoint) IsRequestPayloadNeeded ¶
func (e *EchoEndpoint) IsRequestPayloadNeeded() bool
type Endpoint ¶
type Endpoint interface {
api.Operation
generic_error.ErrorsExtender
MessageHandlers
SetMessageHandlers(handlers MessageHandlers)
NewRequestMessage() interface{}
// Handle request to server API.
HandleRequest(request Request) error
// Precheck request before some authorization methods
PrecheckBeforeAuth(request Request, smsMessage *string, skipSms *bool) error
IsRequestPayloadNeeded() bool
SetRequestPreprocessor(handler EndpointHandler)
GetRequestPreprocessor() EndpointHandler
PreprocessBeforeAuth(request Request) error
SetRequestPostprocessor(handler EndpointHandler)
GetRequestPostprocessor() EndpointHandler
Postprocess(request Request) error
}
Interface of API endpoint.
type EndpointBase ¶
type EndpointBase struct {
api.Operation
generic_error.ErrorsExtenderBase
MessageHandlers
// contains filtered or unexported fields
}
Base type for API endpoints.
func (*EndpointBase) Construct ¶
func (e *EndpointBase) Construct(op api.Operation)
func (*EndpointBase) GetRequestPostprocessor ¶
func (e *EndpointBase) GetRequestPostprocessor() EndpointHandler
func (*EndpointBase) GetRequestPreprocessor ¶
func (e *EndpointBase) GetRequestPreprocessor() EndpointHandler
func (*EndpointBase) HandleRequest ¶
func (e *EndpointBase) HandleRequest(request Request) error
func (*EndpointBase) Init ¶
func (e *EndpointBase) Init(operationName string, accessType ...access_control.AccessType)
func (*EndpointBase) IsRequestPayloadNeeded ¶
func (e *EndpointBase) IsRequestPayloadNeeded() bool
func (*EndpointBase) NewRequestMessage ¶
func (e *EndpointBase) NewRequestMessage() interface{}
func (*EndpointBase) Postprocess ¶
func (e *EndpointBase) Postprocess(request Request) error
func (*EndpointBase) PrecheckBeforeAuth ¶
func (e *EndpointBase) PrecheckBeforeAuth(request Request, smsMessage *string, skipSms *bool) error
func (*EndpointBase) PreprocessBeforeAuth ¶
func (e *EndpointBase) PreprocessBeforeAuth(request Request) error
func (*EndpointBase) SetMessageHandlers ¶
func (e *EndpointBase) SetMessageHandlers(handlers MessageHandlers)
func (*EndpointBase) SetRequestPostprocessor ¶
func (e *EndpointBase) SetRequestPostprocessor(handler EndpointHandler)
func (*EndpointBase) SetRequestPreprocessor ¶
func (e *EndpointBase) SetRequestPreprocessor(handler EndpointHandler)
type EndpointHandler ¶
type EndpointNoHandler ¶
type EndpointNoHandler struct{}
Base type for API endpoints with empty handlers.
func (*EndpointNoHandler) HandleRequest ¶
func (e *EndpointNoHandler) HandleRequest(request Request) error
type EnumGetter ¶
type FieldEnums ¶
type MessageBuilder ¶
type MessageBuilder func() interface{}
type MessageContent ¶
type MessageConverter ¶
type MessageConverter func(msg MessageContent) error
type MessageHandlers ¶
type MessageHandlers interface {
NewTransportRequest(ep Endpoint) interface{}
TransportRequestToLogic(msg MessageContent) error
LogicResponseToTransport(msg MessageContent) error
}
type MessageHandlersConfig ¶
type MessageHandlersConfig struct {
RequestFromTransport MessageConverter
ResponseToTransport MessageConverter
TransportRequestBuilder MessageBuilder
}
func (*MessageHandlersConfig) LogicResponseToTransport ¶
func (m *MessageHandlersConfig) LogicResponseToTransport(msg MessageContent) error
func (*MessageHandlersConfig) NewTransportRequest ¶
func (m *MessageHandlersConfig) NewTransportRequest(ep Endpoint) interface{}
func (*MessageHandlersConfig) TransportRequestToLogic ¶
func (m *MessageHandlersConfig) TransportRequestToLogic(msg MessageContent) error
type Request ¶
type Request interface {
auth.AuthContext
common.WithParameters
Server() Server
Response() Response
Endpoint() Endpoint
ParseAndValidate(cmd interface{}) error
FormData() map[string][]string
FormFile() (*multipart.FileHeader, error)
SetMessage(msg RequestMessage)
Message() RequestMessage
}
Interface of request to server API.
type RequestBase ¶
type RequestBase struct {
auth.TenancyUserContext
auth.SessionBase
// contains filtered or unexported fields
}
func (*RequestBase) Endpoint ¶
func (r *RequestBase) Endpoint() Endpoint
func (*RequestBase) GetSessionParameter ¶
func (r *RequestBase) GetSessionParameter(key string) string
func (*RequestBase) Init ¶
func (r *RequestBase) Init(app app_context.Context, log logger.Logger, db db.DB, fields ...logger.Fields)
func (*RequestBase) LoadSessionParameters ¶
func (r *RequestBase) LoadSessionParameters(parameters map[string]string)
func (*RequestBase) Message ¶
func (r *RequestBase) Message() RequestMessage
func (*RequestBase) SetEndpoint ¶
func (r *RequestBase) SetEndpoint(endpoint Endpoint)
func (*RequestBase) SetMessage ¶
func (r *RequestBase) SetMessage(msg RequestMessage)
func (*RequestBase) SetSessionParameter ¶
func (r *RequestBase) SetSessionParameter(key string, value string)
func (*RequestBase) StoreSessionParameters ¶
func (r *RequestBase) StoreSessionParameters() map[string]string
type RequestMessage ¶
type RequestMessage interface {
MessageContent
}
type RequestMessageBase ¶
type RequestMessageBase struct {
// contains filtered or unexported fields
}
func NewRequestMessage ¶
func NewRequestMessage() *RequestMessageBase
func (*RequestMessageBase) BinaryContent ¶
func (m *RequestMessageBase) BinaryContent() []byte
func (*RequestMessageBase) LogicMessage ¶
func (m *RequestMessageBase) LogicMessage() any
func (*RequestMessageBase) SetBinaryContent ¶
func (m *RequestMessageBase) SetBinaryContent(content []byte)
func (*RequestMessageBase) SetLogicMessage ¶
func (m *RequestMessageBase) SetLogicMessage(msg interface{})
func (*RequestMessageBase) SetTransportMessage ¶
func (m *RequestMessageBase) SetTransportMessage(msg interface{})
func (*RequestMessageBase) TransportMessage ¶
func (m *RequestMessageBase) TransportMessage() any
type ResourceEndpoint ¶
type ResourceEndpoint struct {
api.ResourceBase
EndpointBase
}
type ResourceEndpointI ¶
type Response ¶
type Response interface {
Message() interface{}
SetMessage(message api.Response)
SetStatusMessage(status string)
SetSuccessStatusMessage()
Request() Request
SetRequest(request Request)
Payload() []byte
SetPayload(payload []byte)
SetRedirectPath(path string)
RedirectPath() string
SetFile(file *File)
File() *File
}
Interface of response of server API.
type ResponseBase ¶
type ResponseBase struct {
// contains filtered or unexported fields
}
func (*ResponseBase) File ¶
func (r *ResponseBase) File() *File
func (*ResponseBase) Message ¶
func (r *ResponseBase) Message() interface{}
func (*ResponseBase) Payload ¶
func (r *ResponseBase) Payload() []byte
func (*ResponseBase) RedirectPath ¶
func (r *ResponseBase) RedirectPath() string
func (*ResponseBase) Request ¶
func (r *ResponseBase) Request() Request
func (*ResponseBase) SetFile ¶
func (r *ResponseBase) SetFile(file *File)
func (*ResponseBase) SetMessage ¶
func (r *ResponseBase) SetMessage(message api.Response)
func (*ResponseBase) SetPayload ¶
func (r *ResponseBase) SetPayload(data []byte)
func (*ResponseBase) SetRedirectPath ¶
func (r *ResponseBase) SetRedirectPath(path string)
func (*ResponseBase) SetRequest ¶
func (r *ResponseBase) SetRequest(request Request)
func (*ResponseBase) SetStatusMessage ¶
func (r *ResponseBase) SetStatusMessage(status string)
func (*ResponseBase) SetSuccessStatusMessage ¶
func (r *ResponseBase) SetSuccessStatusMessage()
type Server ¶
type Server interface {
generic_error.ErrorManager
auth.WithAuth
app_context.WithApp
Init(ctx app_context.Context, auth auth.Auth, tenancyManager multitenancy.Multitenancy, configPath ...string) error
// Get API version.
ApiVersion() string
// Run server.
Run(fin background_worker.Finisher)
// Check if hateoas links are enabled.
IsHateoas() bool
// Get tenancy manager
TenancyManager() multitenancy.Multitenancy
// Check for testing mode.
Testing() bool
// Get dynamic tables store
DynamicTables() DynamicTables
// Load default server configuration from corresponding pool service
SetConfigFromPoolService(service pool.PoolService, public ...bool)
// Get pool service used for server configuration
ConfigPoolService() pool.PoolService
RegisterService(Service) error
ListEndpoints()
}
Interface of generic server that implements some API.
type ServerBase ¶
type ServerBase struct {
app_context.WithAppBase
}
func (*ServerBase) ListEndpoints ¶
func (s *ServerBase) ListEndpoints()
type ServerBaseConfig ¶
type ServerBaseConfig struct {
common.WithNameBaseConfig
API_VERSION string `validate:"required"`
HATEOAS bool
OPLOG_USER_TYPE string `default:"server_user"`
DISABLE_MULTITENANCY bool
}
func (*ServerBaseConfig) ApiVersion ¶
func (s *ServerBaseConfig) ApiVersion() string
func (*ServerBaseConfig) IsHateoas ¶
func (s *ServerBaseConfig) IsHateoas() bool
type Service ¶
type Service interface {
generic_error.ErrorsExtender
common.WithName
api.Resource
SetSupportsMultitenancy(enable bool)
SupportsMultitenancy() bool
Server() Server
AttachToServer(server Server) error
AddDynamicTables(tables ...*DynamicTableConfig)
DynamicTables() []*DynamicTableConfig
Package() string
SetPackage(string)
}
Interface of service that implements one or more groups of API endpoints.
type ServiceBase ¶
type ServiceBase struct {
common.WithNameBase
api.ResourceBase
generic_error.ErrorsExtenderBase
// contains filtered or unexported fields
}
func (*ServiceBase) AddDynamicTables ¶
func (s *ServiceBase) AddDynamicTables(tables ...*DynamicTableConfig)
func (*ServiceBase) AttachToServer ¶
func (s *ServiceBase) AttachToServer(server Server) error
func (*ServiceBase) DynamicTables ¶
func (s *ServiceBase) DynamicTables() []*DynamicTableConfig
func (*ServiceBase) Init ¶
func (s *ServiceBase) Init(pathName string, packageName string, multitenancy ...bool)
func (*ServiceBase) InitExplicit ¶
func (s *ServiceBase) InitExplicit(pathName string, serviceName string, packageName string, multitenancy ...bool)
func (*ServiceBase) Package ¶
func (s *ServiceBase) Package() string
func (*ServiceBase) Server ¶
func (s *ServiceBase) Server() Server
func (*ServiceBase) SetEndpointMessageHandlers ¶
func (s *ServiceBase) SetEndpointMessageHandlers(handlers map[string]MessageHandlers)
func (*ServiceBase) SetPackage ¶
func (s *ServiceBase) SetPackage(value string)
func (*ServiceBase) SetSupportsMultitenancy ¶
func (s *ServiceBase) SetSupportsMultitenancy(enable bool)
func (*ServiceBase) SupportsMultitenancy ¶
func (s *ServiceBase) SupportsMultitenancy() bool
type ServiceEachEndpointHandler ¶
type ServiceEachEndpointHandler = func(ep Endpoint)
type StatusResponse ¶
type StatusResponse struct {
api.ResponseStub
Status string `json:"status"`
}
type StatusService ¶
type StatusService struct {
ServiceBase
}
func NewStatusService ¶
func NewStatusService(multitenancy ...bool) *StatusService
Source Files
¶
Click to show internal directories.
Click to hide internal directories.