Documentation ¶
Index ¶
- Constants
- type AuthFunc
- type Base
- type BasicToken
- type Client
- func (c *Client) Do(req *http.Request, timeout ...time.Duration) (*http.Response, error)
- func (c *Client) GetCookies() []*http.Cookie
- func (c *Client) GetToken() string
- func (c *Client) JSONRequest(method string, requestPath string, model interface{}) (*http.Request, error)
- func (c *Client) JSONRequestForExplorer(method string, requestPath string, model interface{}, explorerURL string) (*http.Request, error)
- func (c *Client) MultiFormRequest(method string, requestPath string, field map[string]string, ...) (*http.Request, error)
- func (c *Client) ParseMutilform(resp *http.Response, dirPath string) ([]string, map[string]string, error)
- func (c *Client) SetAuthorization(req *http.Request, token string)
- func (c *Client) SetCookies(cookies []*http.Cookie)
- func (c *Client) SetToken(token string) error
- type ClientOptions
- type ClientToken
- type Connection
- type CookiesType
- type Entity
- type EntityConfig
- type ErrMessage
- type GetTenantCBFunc
- type HandlerFunc
- type InternalTokenHelper
- type LoginRequest
- type LoginResponse
- type Operation
- type Request
- type Result
- type Role
- type Server
- func (s *Server) APIKeyAuthHandle(hf HandlerFunc, ef HandlerFunc) HandlerFunc
- func (s *Server) AddEntity(entitytName string, entityModel interface{}) error
- func (s *Server) AddExtension(fileExtension string, fileType string)
- func (s *Server) AddForienKey(entitytName string, entityModel interface{}, column string, ...) error
- func (s *Server) AddPrefixRoute(prefix string, dirpath string, hf HandlerFunc)
- func (s *Server) AddRoute(path string, method string, hf HandlerFunc)
- func (s *Server) BasicAuthHandle(claims jwt.Claims, hf HandlerFunc, af AuthFunc, ef HandlerFunc) HandlerFunc
- func (s *Server) CreateEntity(entitytName string, value interface{}) error
- func (s *Server) CreateRole(r *Role) error
- func (s *Server) CreateSessionStore(name string, secret string, option sessions.Options)
- func (s *Server) CreateTenant(t *Tenant) error
- func (s *Server) CreateUser(u *User) error
- func (s *Server) CreateUserRole(ur *UserRole) error
- func (s *Server) DeleteEntity(entitytName string, tenantID interface{}, format string, item interface{}, ...) error
- func (s *Server) DeleteUser(tenantID interface{}, id uuid.UUID) error
- func (s *Server) EmptySessionCookies(req *Request, sessionName string) error
- func (s *Server) EnableSWagger(url string)
- func (s *Server) GenerateJWTToken(claims jwt.Claims) string
- func (s *Server) GetDB() *adapter.Adapter
- func (s *Server) GetEntity(entitytName string, tenantID interface{}, format string, item interface{}, ...) error
- func (s *Server) GetQuerry(req *Request, key string) string
- func (s *Server) GetReqHeader(req *Request, key string) string
- func (s *Server) GetRole(name string) (*Role, error)
- func (s *Server) GetRouteVar(req *Request, key string) string
- func (s *Server) GetServerURL() string
- func (s *Server) GetSessionCookies(req *Request, sessionName string, key interface{}) interface{}
- func (s *Server) GetTenant(name string) (*Tenant, error)
- func (s *Server) GetUser(tenantID interface{}, userName string) (*User, error)
- func (s *Server) GetUserByID(tenantID interface{}, id uuid.UUID) (*User, error)
- func (s *Server) GetUserRole(u *User) ([]UserRole, error)
- func (s *Server) GetUsers(tenantID interface{}, format string, value ...interface{}) ([]User, error)
- func (s *Server) IsFORM(req *Request) (bool, error)
- func (s *Server) LoginUser(tenantID interface{}, req *LoginRequest) *LoginResponse
- func (s *Server) ParseFORM(req *Request) (map[string]interface{}, error)
- func (s *Server) ParseJSON(req *Request, model interface{}) error
- func (s *Server) ParseMultiPartForm(req *Request, dirPath string) ([]string, map[string][]string, error)
- func (s *Server) ParseMultiPartFormFile(req *Request, paramName string) (*os.File, *multipart.FileHeader, error)
- func (s *Server) Redirect(req *Request, url string) *Result
- func (s *Server) RenderFile(req *Request, fileName string, attachment bool) *Result
- func (s *Server) RenderImage(req *Request, contentType string, img string) *Result
- func (s *Server) RenderJSON(req *Request, model interface{}, status int) *Result
- func (s *Server) RenderJSONError(req *Request, status int, errMsg string, logMsg string, args ...interface{}) *Result
- func (s *Server) RenderJSONStatus(req *Request, status string, message string, logMsg string, ...) *Result
- func (s *Server) RenderMultiFormFile(req *Request, field map[string]string, fileName map[string]string) *Result
- func (s *Server) RenderTemplate(req *Request, renderPath string, model interface{}, status int) *Result
- func (s *Server) SaveEntity(entitytName string, tenantID interface{}, item interface{}, format string, ...) error
- func (s *Server) ServerStatic(req *Request) *Result
- func (s *Server) SessionAuthHandle(claims jwt.Claims, sessionName string, sessionKey string, hf HandlerFunc, ...) HandlerFunc
- func (s *Server) SetAPIKey(apiKey string)
- func (s *Server) SetAuditLog(log logger.Logger)
- func (s *Server) SetDebugMode()
- func (s *Server) SetDefaultTenant(id uuid.UUID)
- func (s *Server) SetSessionCookies(req *Request, sessionName string, key interface{}, value interface{}) error
- func (s *Server) SetShutdown(sf ShutdownFunc)
- func (s *Server) SetStatic(prefix string, dir string)
- func (s *Server) SetTenantCBFunc(tcb GetTenantCBFunc)
- func (s *Server) SetupEntity(cfg EntityConfig) error
- func (s *Server) Shutdown() error
- func (s *Server) Start() error
- func (s *Server) UpdateEntity(entitytName string, tenantID interface{}, item interface{}, format string, ...) error
- func (s *Server) UpdateUser(u *User) error
- func (s *Server) ValidateJWTToken(token string, claims jwt.Claims) error
- type ServerConfig
- type ServerOptions
- type SessionStore
- type ShutdownFunc
- type StatusMsg
- type Tenant
- type TokenHelper
- type TokenType
- type User
- type UserRole
Constants ¶
const ( UserEntity string = "UserEntity" RoleEntity string = "RoleEntity" UserRoleEntity string = "UserRoleEntity" TenantEntity string = "TenantEntity" DefaultEntity string = "DefaultEntity" )
const ( DefaultTokenHdr string = "X-Token" DefaultRawErrHdr string = "X-Raw" )
const ( StatusSuccess string = "Success" StatusFailed string = "Failed" StatusError string = "Error" StatusBusy string = "Busy" StatusNone string = "None" )
const (
APIKeyHeader string = "X-API-Key"
)
const DefaultTimeout = 60 * time.Second
const (
JSONContentType string = "application/json"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { ID uuid.UUID `gorm:"column:Id;primary_key;type:uniqueidentifier"` CreationTime time.Time `gorm:"column:CreationTime;not null"` CreatorID uuid.UUID `gorm:"column:CreatorId;type:uniqueidentifier"` LastModificationTime time.Time `gorm:"column:LastModificationTime"` LastModifierID uuid.UUID `gorm:"column:LastModifierId;type:uniqueidentifier"` TenantID uuid.UUID `gorm:"column:TenantId;type:uniqueidentifier"` }
Base contains common columns for all tables.
func (*Base) BeforeCreate ¶
BeforeCreate will set a UUID rather than numeric ID.
func (*Base) BeforeSave ¶
BeforeCreate will set a UUID rather than numeric ID.
type BasicToken ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client : Client struct
func (*Client) GetCookies ¶
func (*Client) JSONRequest ¶
func (*Client) JSONRequestForExplorer ¶
func (*Client) MultiFormRequest ¶
func (*Client) ParseMutilform ¶
func (*Client) SetAuthorization ¶
func (*Client) SetCookies ¶
type ClientOptions ¶
func SetClientDefaultTimeout ¶
func SetClientDefaultTimeout(timeout time.Duration) ClientOptions
func SetClientTokenHelper ¶
func SetClientTokenHelper(filename string) ClientOptions
type ClientToken ¶
type Connection ¶
type Connection struct { // RemoteAddr is the network address that sent the request. RemoteAddr string `json:"remote_addr"` // ConnState is the TLS connection state if applicable. ConnState *tls.ConnectionState `sentinel:""` }
Connection represents the connection information for a request.
type CookiesType ¶
type CookiesType map[interface{}]interface{}
type EntityConfig ¶
type ErrMessage ¶
type ErrMessage struct {
Error string `json:"Message"`
}
ErrMessage example
func JSONDecodeErr ¶
func JSONDecodeErr(resp *http.Response) (*ErrMessage, error)
type GetTenantCBFunc ¶
type HandlerFunc ¶
type InternalTokenHelper ¶
type InternalTokenHelper struct {
// contains filtered or unexported fields
}
InternalTokenHelper fulfills the TokenHelper interface when no external token-helper is configured, and avoids shelling out
func NewInternalTokenHelper ¶
func NewInternalTokenHelper(filename string) (*InternalTokenHelper, error)
func (*InternalTokenHelper) Erase ¶
func (i *InternalTokenHelper) Erase() error
Erase erases the value of the token
func (*InternalTokenHelper) Get ¶
func (i *InternalTokenHelper) Get() (string, error)
Get gets the value of the stored token, if any
func (*InternalTokenHelper) Path ¶
func (i *InternalTokenHelper) Path() string
func (*InternalTokenHelper) Store ¶
func (i *InternalTokenHelper) Store(input string) error
Store stores the value of the token to the file. We always overwrite any existing file atomically to ensure that ownership and permissions are set appropriately.
type LoginRequest ¶
type LoginResponse ¶
type Operation ¶
type Operation string
Operation is an enum that is used to specify the type of request being made
type Request ¶
type Request struct { ID string Method string Path string TimeIn time.Time ClientToken ClientToken Connection *Connection Data map[string]interface{} `json:"data" structs:"data" mapstructure:"data"` Model interface{} Headers http.Header TenantID uuid.UUID // contains filtered or unexported fields }
func (*Request) GetHTTPRequest ¶
func (*Request) GetHTTPWritter ¶
func (req *Request) GetHTTPWritter() http.ResponseWriter
type Role ¶
type Role struct { ID uuid.UUID `gorm:"column:Id;primary_key;type:uniqueidentifier"` ConcurrencyStamp string `gorm:"column:ConcurrencyStamp"` ExtraProperties string `gorm:"column:ExtraProperties"` TenantID uuid.UUID `gorm:"column:TenantId;type:uniqueidentifier"` Name string `gorm:"column:Name;not null" json:"Name"` NormalizedName string `gorm:"column:NormalizedName;not null" json:"NormalizedName"` IsDefault bool `gorm:"column:IsDefault;type:bit;not null"` IsStatic bool `gorm:"column:IsStatic;type:bit;not null"` IsPublic bool `gorm:"column:IsPublic;type:bit;not null"` DeleterUserID int64 `gorm:"column:DeleterUserID"` }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server defines server
func NewServer ¶
func NewServer(cfg *config.Config, serverCfg *ServerConfig, log logger.Logger, options ...ServerOptions) (Server, error)
NewServer create new server instances
func (*Server) APIKeyAuthHandle ¶
func (s *Server) APIKeyAuthHandle(hf HandlerFunc, ef HandlerFunc) HandlerFunc
func (*Server) AddExtension ¶
func (*Server) AddForienKey ¶
func (s *Server) AddForienKey(entitytName string, entityModel interface{}, column string, forienEntityName string, forienEntityColumn string) error
DropTable drop the table
func (*Server) AddPrefixRoute ¶
func (s *Server) AddPrefixRoute(prefix string, dirpath string, hf HandlerFunc)
func (*Server) BasicAuthHandle ¶
func (s *Server) BasicAuthHandle(claims jwt.Claims, hf HandlerFunc, af AuthFunc, ef HandlerFunc) HandlerFunc
func (*Server) CreateEntity ¶
func (*Server) CreateSessionStore ¶
func (*Server) CreateTenant ¶
CreateTenant will create tenant
func (*Server) CreateUser ¶
func (*Server) CreateUserRole ¶
CreateUserRole will create user role
func (*Server) DeleteEntity ¶
func (*Server) EmptySessionCookies ¶
func (*Server) EnableSWagger ¶
func (*Server) GenerateJWTToken ¶
GenerateJWTToken will generate JWT token
func (*Server) GetSessionCookies ¶
func (*Server) GetUserByID ¶
func (*Server) GetUserRole ¶
GetUserRole will get user role
func (*Server) LoginUser ¶
func (s *Server) LoginUser(tenantID interface{}, req *LoginRequest) *LoginResponse
func (*Server) ParseMultiPartForm ¶
func (*Server) ParseMultiPartFormFile ¶
func (*Server) RenderFile ¶
func (*Server) RenderImage ¶
func (*Server) RenderJSON ¶
func (*Server) RenderJSONError ¶
func (*Server) RenderJSONStatus ¶
func (*Server) RenderMultiFormFile ¶
func (*Server) RenderTemplate ¶
func (*Server) SaveEntity ¶
func (*Server) ServerStatic ¶
func (*Server) SessionAuthHandle ¶
func (s *Server) SessionAuthHandle(claims jwt.Claims, sessionName string, sessionKey string, hf HandlerFunc, ef HandlerFunc) HandlerFunc
func (*Server) SetAuditLog ¶
func (*Server) SetDebugMode ¶
func (s *Server) SetDebugMode()
func (*Server) SetDefaultTenant ¶
func (*Server) SetSessionCookies ¶
func (*Server) SetShutdown ¶
func (s *Server) SetShutdown(sf ShutdownFunc)
func (*Server) SetTenantCBFunc ¶
func (s *Server) SetTenantCBFunc(tcb GetTenantCBFunc)
func (*Server) SetupEntity ¶
func (s *Server) SetupEntity(cfg EntityConfig) error
func (*Server) UpdateEntity ¶
func (*Server) UpdateUser ¶
func (*Server) ValidateJWTToken ¶
ValidateJWTToken verify token
type ServerConfig ¶
type ServerOptions ¶
func SetServerTimeout ¶
func SetServerTimeout(timeout time.Duration) ServerOptions
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
type ShutdownFunc ¶
type ShutdownFunc func() error
type Tenant ¶
type Tenant struct { Base ExtraProperties string `gorm:"column:ExtraProperties"` ConcurrencyStamp string `gorm:"column:ConcurrencyStamp"` IsDeleted bool `gorm:"column:IsDeleted;not null;type:bit"` DeleterID uuid.UUID `gorm:"column:DeleterId;type:uniqueidentifier"` DeletionTime time.Time `gorm:"column:DeletionTime"` Name string `gorm:"column:Name;not null" json:"Name"` EditionID uuid.UUID `gorm:"column:EditionId;type:uniqueidentifier"` }
Tenant List
type TokenHelper ¶
type TokenType ¶
type TokenType uint8
const ( // TokenTypeDefault means "use the default, if any, that is currently set // on the mount". If not set, results in a Service token. TokenTypeDefault TokenType = iota // TokenTypeService is a "normal" Vault token for long-lived services TokenTypeService // TokenTypeBatch is a batch token TokenTypeBatch )
type User ¶
type User struct { Base ConcurrencyStamp string `gorm:"column:ConcurrencyStamp"` IsDeleted bool `gorm:"column:IsDeleted;not null;type:bit"` DeleterID uuid.UUID `gorm:"column:DeleterId;type:uniqueidentifier"` DeletionTime time.Time `gorm:"column:DeletionTime"` UserName string `gorm:"column:UserName;not null" json:"UserName"` NormalizedUserName string `gorm:"column:NormalizedUserName;not null" json:"NormalizedUserName"` Name string `gorm:"column:Name;size:64;not null" json:"Name"` Surname string `gorm:"column:Surname;size:64;not null" json:"Surname"` Email string `gorm:"column:Email;size:256;not null" json:"Email"` NormalizedEmail string `gorm:"column:NormalizedEmail;size:256;not null" json:"NormalizedEmail"` EmailConfirmed bool `gorm:"column:EmailConfirmed;not null;type:bit"` PasswordHash string `gorm:"column:PasswordHash;not null" json:"PasswordHash"` SecurityStamp string `gorm:"column:SecurityStamp"` IsExternal bool `gorm:"column:IsExternal;type:bit"` PhoneNumber string `gorm:"column:PhoneNumber"` PhoneNumberConfirmed bool `gorm:"column:PhoneNumberConfirmed;not null;type:bit"` TwoFactorEnabled bool `gorm:"column:TwoFactorEnabled;not null;type:bit"` LockoutEnd time.Time `gorm:"column:LockoutEnd"` LockoutEnabled bool `gorm:"column:LockoutEnabled;not null;type:bit"` AccessFailedCount int `gorm:"column:AccessFailedCount;not null"` ExtraProperties string `gorm:"column:ExtraProperties;not null"` Roles []Role }
User user table