Documentation
¶
Index ¶
- Constants
- Variables
- func AuthProviders() []string
- func MapValue[V any](m Map, key string, defaultValues ...V) V
- func PermissionTypeValues() []string
- func RegisterAuthProviderMaker(name string, fn AuthProviderMaker)
- type App
- type Arg
- type ArgType
- type Args
- type AuthConfig
- type AuthProvider
- type AuthProviderMaker
- type Config
- type Context
- type ContextKey
- type Disk
- type DiskBase
- type DiskConfig
- type File
- type HTTPResponse
- type Handler
- type HandlerFn
- type Hookable
- type Hooks
- type IDToken
- type Mail
- type MailConfig
- type Mailer
- type Map
- type Meta
- type Middleware
- type Permission
- type PermissionType
- type ResolveHook
- type Resource
- func Connect[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Delete[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Get[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Head[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func NewResource[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Options[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Patch[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Post[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Put[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func Trace[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func WS[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
- func (r *Resource) Add(resources ...*Resource) (self *Resource)
- func (r *Resource) AddResource(name string, handler Handler, metas ...*Meta) (self *Resource)
- func (r *Resource) Clone() *Resource
- func (r *Resource) Find(resourceID string) *Resource
- func (r *Resource) Group(name string, metas ...*Meta) (group *Resource)
- func (r *Resource) Handler() Handler
- func (r *Resource) ID() string
- func (r *Resource) Init() error
- func (r *Resource) IsGroup() bool
- func (r *Resource) IsPublic() bool
- func (r *Resource) MarshalJSON() ([]byte, error)
- func (r *Resource) Meta() *Meta
- func (r *Resource) Name() string
- func (r *Resource) Print()
- func (r *Resource) Remove(name string) (self *Resource)
- func (r *Resource) Resources() []*Resource
- func (r *Resource) Signature() Signatures
- func (r *Resource) String() string
- type ResourcesManager
- type Result
- type Role
- type Signature
- type Signatures
- type StaticFs
- type StorageConfig
- type SyncMap
- type Traceable
- type User
- type UserJwtClaims
- type WSClient
- type WSCloseType
- type WSMessageType
Constants ¶
const TraceID = "trace_id"
Variables ¶
var AllowedFileTypes = []string{
"text/xml",
"text/xml; charset=utf-8",
"text/plain",
"text/plain; charset=utf-8",
"image/jpeg",
"image/pjpeg",
"image/png",
"image/gif",
"image/x-icon",
"application/pdf",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/powerpoint",
"application/x-mspowerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/mspowerpoint",
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.slideshow",
"application/vnd.oasis.opendocument.text",
"application/excel",
"application/vnd.ms-excel",
"application/x-excel",
"application/x-msexcel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"audio/mpeg3",
"audio/x-mpeg-3",
"video/x-mpeg",
"audio/m4a",
"audio/ogg",
"audio/wav",
"audio/x-wav",
"video/mp4",
"video/x-m4v",
"video/quicktime",
"video/x-ms-asf",
"video/x-ms-wmv",
"application/x-troff-msvideo",
"video/avi",
"video/msvideo",
"video/x-msvideo",
"audio/mpeg",
"video/mpeg",
"video/ogg",
"video/3gpp",
"audio/3gpp",
"video/3gpp2",
"audio/3gpp2",
}
AllowedFileTypes is a list of allowed file types
var (
ContextKeyTraceID = ContextKey(TraceID)
)
var ( // PermissionTypeToStrings is a map that contains the string representation of the enum values PermissionTypeToStrings = [...]string{ PermissionTypeInvalid: "invalid", PermissionTypeAllow: "allow", PermissionTypeDeny: "deny", } )
var RoleAdmin = &Role{ ID: 1, Name: "Admin", Root: true, }
RoleAdmin is the admin role
var RoleGuest = &Role{ ID: 3, Name: "Guest", Root: false, }
RoleGuest is the guest role
var RoleUser = &Role{ ID: 2, Name: "User", Root: false, }
RoleUser is the user role
var SystemSchemaTypes = []any{ Role{}, Permission{}, User{}, File{}, }
Functions ¶
func AuthProviders ¶ added in v0.2.0
func AuthProviders() []string
AuthProviders returns a sorted list of the names of the registered auth providers.
func PermissionTypeValues ¶
func PermissionTypeValues() []string
PermissionTypeValues returns all possible values of the enum.
func RegisterAuthProviderMaker ¶ added in v0.2.0
func RegisterAuthProviderMaker(name string, fn AuthProviderMaker)
RegisterAuthProviderMaker makes an auth provider factory available by the provided name. If RegisterAuthProviderMaker is called twice with the same name or if auth provider factory is nil, it panics.
Types ¶
type App ¶
type App interface {
Hookable
Key() string
Name() string
Config() *Config
SchemaBuilder() *schema.Builder
SystemSchemas() []any
DB() db.Client
Resources() *ResourcesManager
Reload(ctx context.Context, migration *db.Migration) (err error)
Logger() logger.Logger
UpdateCache(ctx context.Context) error
Roles() []*Role
Disk(names ...string) Disk
Disks() []Disk
GetAuthProvider(name string) AuthProvider
Mailer(...string) Mailer
Mailers() []Mailer
AddResource(resource *Resource)
AddMiddlewares(hooks ...Middleware)
}
App is the interface that defines the methods that an app must implement
type Arg ¶
type ArgType ¶
type ArgType int
ArgType define the data type of a field
func (ArgType) MarshalJSON ¶
MarshalJSON marshal an enum value to the quoted json string value
func (*ArgType) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to the enum value
type AuthConfig ¶ added in v0.2.0
type AuthConfig struct {
EnabledProviders []string `json:"enabled_providers"`
Providers map[string]Map `json:"providers"`
}
func (*AuthConfig) Clone ¶ added in v0.2.0
func (ac *AuthConfig) Clone() *AuthConfig
type AuthProvider ¶ added in v0.2.0
type AuthProvider interface {
Name() string
Login(Context) (any, error)
Callback(Context) (*User, error)
VerifyIDToken(Context, IDToken) (*User, error)
}
func CreateAuthProvider ¶ added in v0.2.0
func CreateAuthProvider(name string, config Map, redirectURL string) (AuthProvider, error)
CreateAuthProvider creates an auth provider by the provided name.
type AuthProviderMaker ¶ added in v0.2.0
type AuthProviderMaker func(Map, string) (AuthProvider, error)
type Config ¶
type Config struct {
Dir string `json:"dir"`
AppName string `json:"app_name"`
AppKey string `json:"app_key"`
Port string `json:"port"`
BaseURL string `json:"base_url"`
DashURL string `json:"dash_url"`
APIBaseName string `json:"api_base_name"`
DashBaseName string `json:"dash_base_name"`
Logger logger.Logger `json:"-"`
LoggerConfig *logger.Config `json:"logger_config"` // If Logger is set, LoggerConfig will be ignored
DB db.Client `json:"-"`
DBConfig *db.Config `json:"db_config"` // If DB is set, DBConfig will be ignored
StorageConfig *StorageConfig `json:"storage_config"`
AuthConfig *AuthConfig `json:"auth_config"`
MailConfig *MailConfig `json:"mail_config"`
SystemSchemas []any `json:"-"` // types to build the system schemas
Hooks *Hooks `json:"-"`
HideResourcesInfo bool `json:"hide_resources_info"`
}
type Context ¶
type Context interface {
context.Context
TraceID() string
User() *User
Local(string, ...any) (val any)
Logger() logger.Logger
Bind(any) error
SetArg(string, string) string
Args() map[string]string
Arg(name string, defaults ...string) string
ArgInt(name string, defaults ...int) int
Body() ([]byte, error)
Payload() (*entity.Entity, error)
BodyParser(out any) error
FormValue(key string, defaultValue ...string) string
Resource() *Resource
AuthToken() string
Next() error
Result(...*Result) *Result
Files() ([]*File, error)
Redirect(string) error
WSClient() WSClient
IP() string
}
Context is the interface that defines the methods that a context must implement
type ContextKey ¶ added in v0.5.0
type ContextKey string
func (ContextKey) String ¶ added in v0.5.0
func (c ContextKey) String() string
type Disk ¶
type Disk interface {
Name() string
Root() string
URL(filepath string) string
Delete(c context.Context, filepath string) error
Put(c context.Context, file *File) (*File, error)
PutReader(c context.Context, in io.Reader, size uint64, mime, dst string) (*File, error)
PutMultipart(c context.Context, m *multipart.FileHeader, dsts ...string) (*File, error)
LocalPublicPath() string
}
Disk is the interface that defines the methods that a disk must implement
type DiskBase ¶ added in v0.4.0
DiskBase is designed to be embedded in other disk-related structs that implement the fs.Disk interface. It provides a common set of functionalities for handling files, such as MIME type checking and generating upload paths.
Fields:
- DiskName: A unique identifier for the disk, typically assigned from config.Name.
- Root: The root directory path where files managed by this disk are stored, typically assigned from config.Root.
Methods:
- Name(): Returns the DiskName of the disk. This can be used to retrieve the identifier of the disk.
- IsAllowedMime(mime string): Checks if the provided MIME type is allowed for upload based on a predefined list of allowed file types. Returns true if the MIME type is allowed, false otherwise.
- UploadFilePath(filename string): Generates a path for uploading a file based on the current time and the provided filename. The path includes the year and month as directories, followed by a timestamp and the sanitized filename.
Usage: DiskBase is intended to be used as a foundational component for managing file storage. It can be embedded in other structs to provide them with basic file handling capabilities. The GetURL function should be implemented to suit the specific needs of the application, allowing for flexible URL generation strategies.
Example:
type CustomDisk struct {
fs.DiskBase
// Additional fields and methods specific to CustomDisk
}
func (*DiskBase) IsAllowedMime ¶ added in v0.4.0
func (*DiskBase) UploadFilePath ¶ added in v0.4.0
type DiskConfig ¶
type DiskConfig struct {
Name string `json:"name"`
Driver string `json:"driver"`
Root string `json:"root"`
BaseURL string `json:"base_url"`
PublicPath string `json:"public_path"`
GetBaseURL func() string `json:"-"`
Provider string `json:"provider"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
AccessKeyID string `json:"access_key_id"`
SecretAccessKey string `json:"secret_access_key"`
ACL string `json:"acl"`
}
DiskConfig holds the disk configuration
func (*DiskConfig) Clone ¶
func (dc *DiskConfig) Clone() *DiskConfig
Clone returns a clone of the disk configuration
type File ¶
type File struct {
ID uint64 `json:"id,omitempty"`
Disk string `json:"disk,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
Type string `json:"type,omitempty"`
Size uint64 `json:"size,omitempty"`
UserID uint64 `json:"user_id,omitempty"`
User *User `` /* 137-byte string literal not displayed */
URL string `json:"url,omitempty" fs:"-"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Reader io.Reader `json:"-"`
// contains filtered or unexported fields
}
File holds the file data
type HTTPResponse ¶
type Hookable ¶ added in v0.5.0
type Hookable interface {
Hooks() *Hooks
OnPreResolve(hooks ...Middleware)
OnPostResolve(hooks ...Middleware)
OnPreDBQuery(hooks ...db.PreDBQuery)
OnPostDBQuery(hooks ...db.PostDBQuery)
OnPreDBExec(hooks ...db.PreDBExec)
OnPostDBExec(hooks ...db.PostDBExec)
OnPreDBCreate(hooks ...db.PreDBCreate)
OnPostDBCreate(hooks ...db.PostDBCreate)
OnPreDBUpdate(hooks ...db.PreDBUpdate)
OnPostDBUpdate(hooks ...db.PostDBUpdate)
OnPreDBDelete(hooks ...db.PreDBDelete)
OnPostDBDelete(hooks ...db.PostDBDelete)
}
type Hooks ¶
type Hooks struct {
DBHooks *db.Hooks
PreResolve []ResolveHook
PostResolve []ResolveHook
}
Hooks is a struct that contains app hooks
type MailConfig ¶ added in v0.6.0
type MailConfig struct {
SenderName string `json:"sender_name"`
SenderMail string `json:"sender_mail"`
DefaultClientName string `json:"default_client"`
Clients []Map `json:"clients"`
}
func (*MailConfig) Clone ¶ added in v0.6.0
func (m *MailConfig) Clone() *MailConfig
type Meta ¶
type Meta struct {
// Http method empty means the method is not set/allowed
Get string `json:"get,omitempty"` // Only use for restful method GET
Head string `json:"head,omitempty"` // Only use for restful method HEAD
Post string `json:"post,omitempty"` // Only use for restful method POST
Put string `json:"put,omitempty"` // Only use for restful method PUT
Delete string `json:"delete,omitempty"` // Only use for restful method DELETE
Connect string `json:"connect,omitempty"` // Only use for restful method CONNECT
Options string `json:"options,omitempty"` // Only use for restful method OPTIONS
Trace string `json:"trace,omitempty"` // Only use for restful method TRACE
Patch string `json:"patch,omitempty"` // Only use for restful method PATCH
// WS
WS string `json:"ws,omitempty"` // Only use for websocket
Prefix string `json:"prefix,omitempty"` // Only use for group resource
Args Args `json:"args,omitempty"`
Public bool `json:"public,omitempty"`
Signatures Signatures `json:"-"`
}
Meta hold extra data, ex: request method, path, etc
type Middleware ¶
Middleware is a function that can be used to add middleware to a resource
type Permission ¶
type Permission struct {
ID int `json:"id,omitempty"`
RoleID uint64 `json:"role_id,omitempty"`
Resource string `json:"resource,omitempty"`
Value string `json:"value,omitempty"`
Modifier string `json:"modifier,omitempty" fs:"type=json;optional"`
Role *Role `` /* 143-byte string literal not displayed */
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
RuleProgram *expr.Program[*Permission, bool] `json:"-"` // The compiled rule program
// contains filtered or unexported fields
}
Permission is a struct that contains the permission data
func (*Permission) Compile ¶ added in v0.6.0
func (p *Permission) Compile() (err error)
func (*Permission) IsAllowed ¶ added in v0.6.0
func (p *Permission) IsAllowed() bool
func (*Permission) IsDenied ¶ added in v0.6.0
func (p *Permission) IsDenied() bool
type PermissionType ¶
type PermissionType uint
PermissionType is an enum that represents the type of a permission
const ( PermissionTypeInvalid PermissionType = iota PermissionTypeAllow PermissionTypeDeny )
func GetPermissionTypeFromName ¶
func GetPermissionTypeFromName(name string) PermissionType
GetPermissionTypeFromName returns the type from a string.
func (PermissionType) MarshalJSON ¶
func (p PermissionType) MarshalJSON() ([]byte, error)
MarshalJSON marshal an enum value to the quoted json string value
func (PermissionType) String ¶
func (p PermissionType) String() string
String returns the string representation of a type.
func (*PermissionType) UnmarshalJSON ¶
func (p *PermissionType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
func (PermissionType) Valid ¶
func (p PermissionType) Valid() bool
Valid reports if the given type if known type.
type ResolveHook ¶
type ResolveHook = Middleware
ResolveHook is a function that can be used to add hooks to a resource
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource is a resource that can be used to define a resource tree
func Connect ¶
func Connect[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Connect is a shortcut to create a new resource with rest method CONNECT and using name as the connect path
func Delete ¶
func Delete[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Delete is a shortcut to create a new resource with rest method DELETE and using name as the delete path
func Get ¶
func Get[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Get is a shortcut to create a new resource with rest method GET and using name as the get path
func Head ¶
func Head[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Head is a shortcut to create a new resource with rest method HEAD and using name as the head path
func NewResource ¶
func NewResource[Input, Output any]( name string, handler HandlerFn[Input, Output], metas ...*Meta, ) *Resource
NewResource creates a new resource with the given name, handler and meta
handler is a function that takes a context and an input and returns an output and an error If the solver input type is not "any", the input will be parsed from the context
func Options ¶
func Options[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Options is a shortcut to create a new resource with rest method OPTIONS and using name as the options path
func Patch ¶
func Patch[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Patch is a shortcut to create a new resource with rest method PATCH and using name as the patch path
func Post ¶
func Post[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Post is a shortcut to create a new resource with rest method POST and using name as the post path
func Put ¶
func Put[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Put is a shortcut to create a new resource with rest method PUT and using name as the put path
func Trace ¶
func Trace[Input, Output any](name string, handler HandlerFn[Input, Output], metas ...*Meta) *Resource
Trace is a shortcut to create a new resource with rest method TRACE and using name as the trace path
func WS ¶ added in v0.3.0
WS is a shortcut to create a new resource with rest method WS and using name as the ws path
func (*Resource) Add ¶
Add adds a new resource to the current resource as a child and returns the current resource
func (*Resource) AddResource ¶
AddResource adds a new resource to the current resource as a child and returns the current resource extras can be used to pass additional information to the resource. Currently supported extras are:
- *Meta: used to pass meta information to the resource, example: &Meta{"rest.POST": "/login"}
- *Signature: used to pass input and output signatures to the resource, example: &Signature{Input: LoginData{}, Output: LoginResponse{}}
func (*Resource) Find ¶
Find returns the resource with the given id The id is in the format of "group1.group2.group3.resource" While group1, group2 and group3 are name of the groups and resource is the name of the resource
func (*Resource) Group ¶
Group creates a new resource group and adds it to the current resource as a child and returns the group resource
func (*Resource) MarshalJSON ¶
MarshalJSON marshals the resource to json
func (*Resource) Signature ¶
func (r *Resource) Signature() Signatures
Signature returns the signature of the resource
type ResourcesManager ¶
type ResourcesManager struct {
*Resource
Middlewares []Middleware
Hooks func() *Hooks
}
ResourcesManager is a resource manager that can be used to manage resources
func NewResourcesManager ¶
func NewResourcesManager() *ResourcesManager
NewResourcesManager creates a new resources manager
func (*ResourcesManager) Clone ¶
func (rs *ResourcesManager) Clone() *ResourcesManager
Clone clones the resource manager and all sub resources
func (*ResourcesManager) Init ¶
func (rs *ResourcesManager) Init() error
Init validates the resource and all sub resources
type Result ¶
type Result struct {
Error *errors.Error `json:"error,omitempty"`
Data any `json:"data,omitempty"`
}
Result is a struct that contains the result of a resolver
type Role ¶
type Role struct {
ID uint64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty" fs:"optional"`
Root bool `json:"root,omitempty" fs:"optional"`
Users []*User `json:"users,omitempty" fs.relation:"{'type':'m2m','schema':'user','field':'roles','owner':true}"`
Permissions []*Permission `json:"permissions,omitempty" fs.relation:"{'type':'o2m','schema':'permission','field':'role','owner':true}"`
Rule string `json:"rule" fs:"optional"`
RuleProgram *expr.Program[*Role, bool] `json:"-"` // The compiled rule program
CreatedAt *time.Time `json:"created_at,omitempty" fs:"default=NOW()"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// contains filtered or unexported fields
}
Role is a struct that contains the role data
type Signatures ¶
type Signatures = []any
Signatures hold the input and output types of a resolver
The first element is the input type
The second element is the output type
Each element is a type of any or a *Signature
For example:
- []any{&LoginData{}, &LoginResponse{}} // The input type is *LoginData and the output type is *LoginResponse
- []any{int, string} // The input type is int and the output type is string
- []any{&Signature{Type: dynamicStruct, Name: "Dynamic"}, int}: dynamic struct doesn't have name, use *Signature to define it
type StorageConfig ¶
type StorageConfig struct {
DefaultDisk string `json:"default_disk"`
Disks []*DiskConfig `json:"disks"`
}
StorageConfig holds the storage configuration
func (*StorageConfig) Clone ¶
func (sc *StorageConfig) Clone() *StorageConfig
Clone returns a clone of the storage configuration
type SyncMap ¶ added in v0.3.0
func NewSyncMap ¶ added in v0.3.0
func (*SyncMap[K, V]) LoadOrStore ¶ added in v0.3.0
type User ¶
type User struct {
ID uint64 `json:"id,omitempty"`
Username string `json:"username,omitempty" fs:"optional"`
Email string `json:"email,omitempty" fs:"optional"`
FirstName string `json:"first_name,omitempty" fs:"optional"`
LastName string `json:"last_name,omitempty" fs:"optional"`
Password string `` /* 198-byte string literal not displayed */
Active bool `json:"active,omitempty" fs:"optional"`
Provider string `json:"provider,omitempty" fs:"optional"`
ProviderID string `json:"provider_id,omitempty" fs:"optional"`
ProviderUsername string `json:"provider_username,omitempty" fs:"optional"`
ProviderProfileImage string `json:"provider_profile_image,omitempty" fs:"optional"`
RoleIDs []uint64 `json:"role_ids,omitempty"`
Roles []*Role `json:"roles,omitempty" fs.relation:"{'type':'m2m','schema':'role','field':'users','owner':false}"`
Files []*File `json:"files,omitempty" fs.relation:"{'type':'o2m','schema':'file','field':'user','owner':true}"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// contains filtered or unexported fields
}
User is a struct that contains user data
type UserJwtClaims ¶
type UserJwtClaims struct {
jwt.RegisteredClaims
User *User `json:"user"`
}
UserJwtClaims is a struct that contains the user jwt claims
type WSCloseType ¶ added in v0.3.0
type WSCloseType int
const ( WSCloseTypeInvalid WSCloseType = iota + 999 WSCloseNormalClosure WSCloseGoingAway WSCloseProtocolError WSCloseUnsupportedData WSCloseSkipReserved WSCloseNoStatusReceived WSCloseAbnormalClosure WSCloseInvalidFramePayloadData WSClosePolicyViolation WSCloseMessageTooBig WSCloseMandatoryExtension WSCloseInternalServerErr WSCloseServiceRestart WSCloseTryAgainLater WSCloseSkipBadGateway WSCloseTLSHandshake )
func WSCloseTypeFromInt ¶ added in v0.3.0
func WSCloseTypeFromInt(i int) WSCloseType
func (WSCloseType) Int ¶ added in v0.3.0
func (t WSCloseType) Int() int
Int returns the int value of the type
func (WSCloseType) Valid ¶ added in v0.3.0
func (t WSCloseType) Valid() bool
Valid reports if the given type if known type.
type WSMessageType ¶ added in v0.3.0
type WSMessageType int
const ( WSMessageInvalid WSMessageType = 0 WSMessageText WSMessageType = 1 WSMessageBinary WSMessageType = 2 WSMessageClose WSMessageType = 8 WSMessagePing WSMessageType = 9 WSMessagePong WSMessageType = 10 )
func WSMessageTypeFromInt ¶ added in v0.3.0
func WSMessageTypeFromInt(i int) WSMessageType
func (WSMessageType) Int ¶ added in v0.3.0
func (t WSMessageType) Int() int
Int returns the int value of the type
func (WSMessageType) Valid ¶ added in v0.3.0
func (t WSMessageType) Valid() bool
Valid reports if the given type if known type.