Documentation
¶
Index ¶
- Variables
- func CreateObject[T Object](h *Handler, c echo.Context, object T) error
- func DeleteObject[T Object](h *Handler, c echo.Context, object T, builder QueryBuilderFunc, ...) error
- func GetObject[T Object](h *Handler, c echo.Context, object T, builder QueryBuilderFunc, ...) error
- func ListObjects[T Object](h *Handler, c echo.Context, objects []T, builder QueryBuilderFunc, ...) error
- func ReplaceObject[T Object](h *Handler, c echo.Context, object T, builder QueryBuilderFunc, ...) error
- type API
- type Attachment
- type Category
- type Configuration
- type Document
- type Group
- type Handler
- func (h *Handler) CleanJWTs() error
- func (h *Handler) CreateAPI(c echo.Context) error
- func (h *Handler) CreateAttachment(c echo.Context) error
- func (h *Handler) CreateCategory(c echo.Context) error
- func (h *Handler) CreateDocument(c echo.Context) error
- func (h *Handler) CreateDocumentFile(c echo.Context) error
- func (h *Handler) CreateGroup(c echo.Context) error
- func (h *Handler) CreateLink(c echo.Context) error
- func (h *Handler) CreateNotification(c echo.Context) error
- func (h *Handler) CreateRole(c echo.Context) error
- func (h *Handler) CreateSpecification(c echo.Context) error
- func (h *Handler) CreateTag(c echo.Context) error
- func (h *Handler) CreateUser(c echo.Context) error
- func (h *Handler) DeleteAPI(c echo.Context) error
- func (h *Handler) DeleteAccount(c echo.Context) error
- func (h *Handler) DeleteAttachment(c echo.Context) error
- func (h *Handler) DeleteCategory(c echo.Context) error
- func (h *Handler) DeleteDocument(c echo.Context) error
- func (h *Handler) DeleteDocumentFile(c echo.Context) error
- func (h *Handler) DeleteFileOrDir(dirname string, filename string) error
- func (h *Handler) DeleteGroup(c echo.Context) error
- func (h *Handler) DeleteJWT(c echo.Context) error
- func (h *Handler) DeleteLink(c echo.Context) error
- func (h *Handler) DeleteNotification(c echo.Context) error
- func (h *Handler) DeleteRole(c echo.Context) error
- func (h *Handler) DeleteSpecification(c echo.Context) error
- func (h *Handler) DeleteTag(c echo.Context) error
- func (h *Handler) DeleteUser(c echo.Context) error
- func (h *Handler) Error(c echo.Context, code int, err error) error
- func (h *Handler) GenerateToken(c echo.Context) error
- func (h *Handler) GetAPI(c echo.Context) error
- func (h *Handler) GetAPIThumbnail(c echo.Context) error
- func (h *Handler) GetAttachment(c echo.Context) error
- func (h *Handler) GetAttachmentBlob(c echo.Context) error
- func (h *Handler) GetBlob(c echo.Context, dirname string, filename string) error
- func (h *Handler) GetCategory(c echo.Context) error
- func (h *Handler) GetConfigurations(c echo.Context) error
- func (h *Handler) GetDocument(c echo.Context) error
- func (h *Handler) GetDocumentBlob(c echo.Context) error
- func (h *Handler) GetDocumentFile(c echo.Context) error
- func (h *Handler) GetGroup(c echo.Context) error
- func (h *Handler) GetLink(c echo.Context) error
- func (h *Handler) GetLinkThumbnail(c echo.Context) error
- func (h *Handler) GetNotification(c echo.Context) error
- func (h *Handler) GetRole(c echo.Context) error
- func (h *Handler) GetSpecification(c echo.Context) error
- func (h *Handler) GetSpecificationBlob(c echo.Context) error
- func (h *Handler) GetTag(c echo.Context) error
- func (h *Handler) GetUser(c echo.Context) error
- func (h *Handler) GetUserIcon(c echo.Context) error
- func (h *Handler) GuestAccess(c echo.Context) bool
- func (h *Handler) ListAPIs(c echo.Context) error
- func (h *Handler) ListAttachments(c echo.Context) error
- func (h *Handler) ListCategories(c echo.Context) error
- func (h *Handler) ListDocumentFiles(c echo.Context) error
- func (h *Handler) ListDocuments(c echo.Context) error
- func (h *Handler) ListGroups(c echo.Context) error
- func (h *Handler) ListJWTs(c echo.Context) error
- func (h *Handler) ListLinks(c echo.Context) error
- func (h *Handler) ListNotifications(c echo.Context) error
- func (h *Handler) ListRoles(c echo.Context) error
- func (h *Handler) ListScopes(c echo.Context) error
- func (h *Handler) ListSpecifications(c echo.Context) error
- func (h *Handler) ListTags(c echo.Context) error
- func (h *Handler) ListUsers(c echo.Context) error
- func (h *Handler) NotImplemented(c echo.Context) error
- func (h *Handler) ReplaceAPI(c echo.Context) error
- func (h *Handler) ReplaceAccount(c echo.Context) error
- func (h *Handler) ReplaceAccountIcon(c echo.Context) error
- func (h *Handler) ReplaceCategory(c echo.Context) error
- func (h *Handler) ReplaceConfigurations(c echo.Context) error
- func (h *Handler) ReplaceDocument(c echo.Context) error
- func (h *Handler) ReplaceGroup(c echo.Context) error
- func (h *Handler) ReplaceLink(c echo.Context) error
- func (h *Handler) ReplaceNotification(c echo.Context) error
- func (h *Handler) ReplaceRole(c echo.Context) error
- func (h *Handler) ReplaceSpecification(c echo.Context) error
- func (h *Handler) ReplaceTag(c echo.Context) error
- func (h *Handler) ReplaceUser(c echo.Context) error
- func (h *Handler) RequestUser(c echo.Context) (*User, error)
- func (h *Handler) RevokeToken(c echo.Context) error
- func (h *Handler) SaveFile(fileHeader *multipart.FileHeader, dirname string) error
- func (h *Handler) SaveFormFiles(c echo.Context, dirname string) ([]*multipart.FileHeader, error)
- func (h *Handler) SetAPIThumbnail(c echo.Context) error
- func (h *Handler) SetLinkThumbnail(c echo.Context) error
- func (h *Handler) SetUserIcon(c echo.Context) error
- func (h *Handler) UnsetAPIThumbnail(c echo.Context) error
- func (h *Handler) UnsetLinkThumbnail(c echo.Context) error
- func (h *Handler) UnsetUserIcon(c echo.Context) error
- func (h *Handler) UpdateAccountPassword(c echo.Context) error
- func (h *Handler) UpdateUserPassword(c echo.Context) error
- func (h *Handler) UserScopes(userId string) []string
- type JWT
- type Link
- type Notification
- type Object
- type QueryBuilderFunc
- type Role
- type Scope
- type Specification
- type Tag
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( JWTLifetime = 24 * time.Hour RefreshTokenLifetime = 7 * 24 * time.Hour )
View Source
var ( ErrNoFileUploaded = errors.New("no file uploaded") ErrFileAlreadyExists = errors.New("file already exists") ErrInvalidLimitRange = errors.New("limit should be integer in [0..200]") ErrInvalidOffsetRange = errors.New("offset should be positive integer") )
View Source
var ( ScopeWriteAPIs = "apis.write" ScopeWriteTags = "tags.write" ScopeWriteCategories = "categories.write" ScopeWriteLinks = "links.write" ScopeWriteNotifications = "notifications.write" ScopeReadUsers = "users.read" ScopeWriteUsers = "users.write" ScopeReadGroups = "groups.read" ScopeWriteGroups = "groups.write" ScopeReadRoles = "roles.read" ScopeWriteRoles = "roles.write" ScopeWriteConfig = "config.write" ScopeReadScopes = "scopes.read" ScopesAvailable = map[string]string{ ScopeWriteAPIs: "update or delete apis", ScopeWriteTags: "update or delete tags", ScopeWriteCategories: "update or delete categories", ScopeWriteLinks: "update or delete links", ScopeWriteNotifications: "update or delete notifications", ScopeReadUsers: "read or list users", ScopeWriteUsers: "update or delete users", ScopeReadGroups: "read or list groups", ScopeWriteGroups: "update or delete groups", ScopeReadRoles: "read or list roles", ScopeWriteRoles: "update or delete roles", ScopeWriteConfig: "update or delete configurations", ScopeReadScopes: "list available scopes", } )
View Source
var (
ErrInvalidUserPassword = errors.New("invalud user password")
)
View Source
var (
ErrNotificationTypeInvalid = errors.New("notification type is invalid")
)
View Source
var (
ErrRefreshTokenExpired = errors.New("refresh token has expired")
)
Functions ¶
func CreateObject ¶
func DeleteObject ¶
func DeleteObject[T Object](h *Handler, c echo.Context, object T, builder QueryBuilderFunc, associations ...string) error
func GetObject ¶
func GetObject[T Object](h *Handler, c echo.Context, object T, builder QueryBuilderFunc, associations ...string) error
func ListObjects ¶
func ListObjects[T Object](h *Handler, c echo.Context, objects []T, builder QueryBuilderFunc, associations ...string) error
func ReplaceObject ¶
func ReplaceObject[T Object](h *Handler, c echo.Context, object T, builder QueryBuilderFunc, associations ...string) error
Types ¶
type API ¶
type API struct { ID string `json:"id" gorm:"primary_key;size:36"` Title string `json:"title"` Description string `json:"description"` Visibility string `json:"visibility"` // public, internal, private Tags []*Tag `json:"tags" gorm:"many2many:api_tags"` Categories []*Category `json:"categories" gorm:"many2many:api_categories"` Attachments []*Attachment `json:"attachments" gorm:"foreignKey:ApiID"` OwnerUser string `json:"owner_user" gorm:"size:36"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
type Attachment ¶
type Attachment struct { ID string `json:"id" gorm:"primary_key;size:36"` ApiID string `json:"-" gorm:"size:36"` Filename string `json:"filename"` Size int64 `json:"size"` ContentType string `json:"-"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
func (*Attachment) Field ¶
func (l *Attachment) Field(field string) any
type Category ¶
type Category struct { ID string `json:"id" gorm:"primary_key;size:36"` Title string `json:"title" gorm:"unique"` Description string `json:"description"` APIs []*API `json:"-" gorm:"many2many:api_categories"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
type Configuration ¶
type Configuration struct { Title string `json:"title"` Description string `json:"description"` SigningSecret []byte `json:"-"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
func (*Configuration) Field ¶
func (c *Configuration) Field(field string) any
func (*Configuration) LoadFromDB ¶
func (c *Configuration) LoadFromDB(db *gorm.DB) error
type Document ¶
type Document struct { ID string `json:"id" gorm:"primary_key;size:36"` ApiID string `json:"-" gorm:"size:36"` Title string `json:"title"` Description string `json:"description"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
type Group ¶
type Group struct { ID string `json:"id" gorm:"primary_key;size:36"` Name string `json:"name" gorm:"unique"` Description string `json:"description"` Users []*User `json:"-" gorm:"many2many:user_groups"` Roles []*Role `json:"roles" gorm:"many2many:group_roles"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) CreateAttachment ¶
func (*Handler) CreateCategory ¶
func (*Handler) CreateDocument ¶
func (*Handler) CreateDocumentFile ¶
func (*Handler) CreateGroup ¶
func (*Handler) CreateLink ¶
func (*Handler) CreateNotification ¶
func (*Handler) CreateRole ¶
func (*Handler) CreateSpecification ¶
func (*Handler) CreateUser ¶
func (*Handler) DeleteAccount ¶
func (*Handler) DeleteAttachment ¶
func (*Handler) DeleteCategory ¶
func (*Handler) DeleteDocument ¶
func (*Handler) DeleteDocumentFile ¶
func (*Handler) DeleteFileOrDir ¶
func (*Handler) DeleteGroup ¶
func (*Handler) DeleteLink ¶
func (*Handler) DeleteNotification ¶
func (*Handler) DeleteRole ¶
func (*Handler) DeleteSpecification ¶
func (*Handler) DeleteUser ¶
func (*Handler) GenerateToken ¶
func (*Handler) GetAPIThumbnail ¶
func (*Handler) GetAttachment ¶
func (*Handler) GetAttachmentBlob ¶
func (*Handler) GetCategory ¶
func (*Handler) GetConfigurations ¶
func (*Handler) GetDocument ¶
func (*Handler) GetDocumentBlob ¶
func (*Handler) GetDocumentFile ¶
func (*Handler) GetLinkThumbnail ¶
func (*Handler) GetNotification ¶
func (*Handler) GetSpecification ¶
func (*Handler) GetSpecificationBlob ¶
func (*Handler) GetUserIcon ¶
func (*Handler) GuestAccess ¶
func (*Handler) ListAttachments ¶
func (*Handler) ListCategories ¶
func (*Handler) ListDocumentFiles ¶
func (*Handler) ListDocuments ¶
func (*Handler) ListGroups ¶
func (*Handler) ListNotifications ¶
func (*Handler) ListScopes ¶
func (*Handler) ListSpecifications ¶
func (*Handler) NotImplemented ¶
func (*Handler) ReplaceAPI ¶
func (*Handler) ReplaceAccount ¶
func (*Handler) ReplaceAccountIcon ¶
func (*Handler) ReplaceCategory ¶
func (*Handler) ReplaceConfigurations ¶
func (*Handler) ReplaceDocument ¶
func (*Handler) ReplaceGroup ¶
func (*Handler) ReplaceLink ¶
func (*Handler) ReplaceNotification ¶
func (*Handler) ReplaceRole ¶
func (*Handler) ReplaceSpecification ¶
func (*Handler) ReplaceTag ¶
func (*Handler) ReplaceUser ¶
func (*Handler) RequestUser ¶
func (*Handler) RevokeToken ¶
func (*Handler) SaveFile ¶
func (h *Handler) SaveFile(fileHeader *multipart.FileHeader, dirname string) error
func (*Handler) SaveFormFiles ¶
func (h *Handler) SaveFormFiles(c echo.Context, dirname string) ([]*multipart.FileHeader, error)
func (*Handler) SetAPIThumbnail ¶
func (*Handler) SetLinkThumbnail ¶
func (*Handler) SetUserIcon ¶
func (*Handler) UnsetAPIThumbnail ¶
func (*Handler) UnsetLinkThumbnail ¶
func (*Handler) UnsetUserIcon ¶
func (*Handler) UpdateAccountPassword ¶
func (*Handler) UpdateUserPassword ¶
func (*Handler) UserScopes ¶
type JWT ¶
type JWT struct { ID string `json:"id" gorm:"size:36;primarykey"` UserID string `json:"user_id" gorm:"size:36"` Token string `json:"-"` Expires int64 `json:"expires"` RefreshToken string `json:"-"` RefreshExpires int64 `json:"refresh_expires"` CreatedAt time.Time `json:"created_at"` DeletedAt *time.Time `json:"-" gorm:"index"` }
type Link ¶
type Notification ¶
type Notification struct { ID string `json:"id" gorm:"primary_key;size:36"` Title string `json:"title"` Description string `json:"description"` Type string `json:"type"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
func (*Notification) Field ¶
func (n *Notification) Field(field string) any
type QueryBuilderFunc ¶
type Role ¶
type Role struct { ID string `json:"id" gorm:"primary_key;size:36"` Name string `json:"name" gorm:"unique"` Description string `json:"description"` Scopes []*Scope `json:"scopes" gorm:"many2many:role_scopes"` Users []*User `json:"-" gorm:"many2many:user_roles"` Groups []*Group `json:"-" gorm:"many2many:group_roles"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
type Scope ¶
type Specification ¶
type Specification struct { ID string `json:"id" gorm:"primary_key;size:36"` ApiID string `json:"-" gorm:"size:36"` Title string `json:"title` Description string `json:"description` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
func (*Specification) Field ¶
func (s *Specification) Field(field string) any
type Tag ¶
type User ¶
type User struct { ID string `json:"id" gorm:"primary_key;size:36"` Username string `json:"username" gorm:"unique"` Email string `json:"email" gorm:"unique"` Firstname string `json:"firstname"` Lastname string `json:"lastname"` Password string `json:"-"` Groups []*Group `json:"groups" gorm:"many2many:user_groups"` Roles []*Role `json:"roles" gorm:"many2many:user_roles"` JWTs []*JWT `json:"-" gorm:"foreignKey:UserID"` APIs []*API `json:"-" gorm:"foreignKey:OwnerUser"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"-" sql:"index"` }
Click to show internal directories.
Click to hide internal directories.