Documentation
¶
Index ¶
- Constants
- Variables
- func NewTestAuthenticator(claim misc.JwtClaim, rs bool) testAuthenticator
- type Action
- type Api
- type Authenticator
- type Authorizer
- type DuplexConnection
- type DuplexHandler
- type DuplexHandlerDefinition
- type DuplexMessage
- type DuplexModule
- type FileHeader
- type FileMultipart
- type HTTPMethod
- type LogHandler
- type Module
- type Multipart
- type MultipartDefinition
- type MultipartFileDefinition
- type MultipartValueDefinition
- type Request
- type RequestDefinition
- type RequestParameter
- type ResponseDefinition
- type Verifier
Constants ¶
View Source
const ( KeyRole = "Role" KeyQuery = "Query" KeyAuth = "Auth" KeyDTO = "DTO" KeyFile = "File" MaxLimit = "MaxLimit" )
Variables ¶
View Source
var ResourceIdParameter = RequestParameter{ Definition: misc.NewQueryDefinition(misc.Id, []misc.QueryOperator{misc.QueryOperatorEqual}, misc.DataTypeString), Query: false, Optional: false, }
Functions ¶
func NewTestAuthenticator ¶
Types ¶
type Api ¶
type Api interface {
Run(ip string, port uint, mode string) error
AppendDuplexModule(mod DuplexModule)
AppendModule(mod Module)
AppendPreHandlers(string, Action)
GetRoute(url, method string) *RequestDefinition
AppendAuthorizer(baseURL string, authorizer Authorizer)
AppendAuthenticator(baseURL string, authorizer Authenticator)
SetCors(cors []string)
SetLogHandler(LogHandler)
SetLogPolicy(model.LogPolicy)
TestHandle(*httptest.ResponseRecorder, *http.Request) error
// OpenAPI
SetExternalDocs(openapi.ExternalDocs)
SetInfo(openapi.Info)
SetContact(openapi.Contact)
SetServers([]openapi.Server)
EnableOpenApi(route string) error
SetErrors([]string)
}
The Api interface defines the methods required to run an HTTP server and handle incoming requests.
type Authenticator ¶
type DuplexConnection ¶
type DuplexHandler ¶
type DuplexHandler func(msg DuplexMessage)
type DuplexHandlerDefinition ¶
type DuplexHandlerDefinition struct {
Topic string
Dto any
Handler DuplexHandler
AnyPermissions []string
FreeRoute bool // Free route require neither authentication nor authorization
}
type DuplexMessage ¶
type DuplexModule ¶
type DuplexModule interface {
GetDuplexHandlers() []*DuplexHandlerDefinition
GetBaseURL() string
OnDuplexConnected(DuplexConnection)
OnDuplexDisconnected(DuplexConnection)
}
type FileHeader ¶
type FileHeader interface {
GetHeader() textproto.MIMEHeader
GetSize() int64
GetFilename() string
OpenFile() (fileProtocol.File, error)
}
type FileMultipart ¶
type FileMultipart interface {
fileProtocol.File
Multipart
}
type HTTPMethod ¶
type HTTPMethod string
type LogHandler ¶
type Module ¶
type Module interface {
GetRequestHandlers() []*RequestDefinition
GetBaseURL() string
GetTag() openapi.Tag
}
The Module interface defines the methods required to handle a group of related request handlers.
type Multipart ¶
type Multipart interface {
io.ReadCloser
GetPartName() string
GetMimeType() string
}
type MultipartDefinition ¶
type MultipartFileDefinition ¶
type MultipartFileDefinition interface {
MultipartDefinition
Verify(FileHeader) error
}
type MultipartValueDefinition ¶
type MultipartValueDefinition interface {
MultipartDefinition
Verify() error
}
type Request ¶
type Request interface {
// GetJson and other stuff
SetServerError(msg string)
SetForbidden()
SetBadRequest(msg string, code string)
SetNotFound(msg string, code string)
ReturnStatus(int, error)
Set(key string, value interface{})
SetFile(key string, f FileHeader)
SetFiles(key string, f []FileHeader)
Get(key string) (interface{}, bool)
MustGet(key string) interface{}
GetDTO() (interface{}, bool)
MustGetDTO() interface{}
GetFile(partName string) (FileHeader, bool)
MustGetFile(partName string) FileHeader
GetFiles(partName string) ([]FileHeader, bool)
MustGetFiles(partName string) []FileHeader
Negotiate(stausCode int, err error, dto interface{})
RangeFile(status int, err error, file fileProtocol.SeekerFile)
WriteFile(status int, err error, file fileProtocol.File)
ReturnMultipartMixed(status int, err error, out ...Multipart)
GetPagination() (misc.Pagination, bool)
GetCursorPagination() (misc.CursorPagination, bool)
GetCaller() (misc.Caller, bool)
MustGetCaller() misc.Caller
GetSort() []misc.Sort
GetQuery() []misc.Query
GetDefaultQuery() (string, bool)
IsAndQuery() bool
}
The Request interface defines the methods available to an HTTP request handler.
type RequestDefinition ¶
type RequestDefinition struct {
Route string
Parameters []RequestParameter
Dto Verifier
DtoArray Verifier
FileParts []MultipartFileDefinition
ValueParts []MultipartValueDefinition
Handler Action
MaxLimit int
Method HTTPMethod
AnyPermissions []string
FreeRoute bool // Free route require neither authentication nor authorization
// Specific for Swagger
Summary string
Description string
OperationId string // Tools use this UNIQUE id to idenitfy the action example: GetUserById,GetUsers, ....
Deprecated bool // Set true if this definition is deprecated
ResponseDefinitions []ResponseDefinition
}
type RequestParameter ¶
type RequestParameter struct {
Definition misc.QueryDefinition
Query bool
Optional bool
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.