Documentation ¶
Index ¶
- Constants
- Variables
- func AuthProxy(config *Config, requestInterceptor func(req *fasthttp.Request), ...) fasthttp.RequestHandler
- func BuildRpc(rpc Rpc) (err error)
- func ConvertRequestCtxToHTTPRequest(ctx *fasthttp.RequestCtx) (*http.Request, error)
- func CorsMiddleware(config *Config) fasthttp.RequestHandler
- func Debug(message string, v ...any)
- func Error(message string, v ...any)
- func ExecuteRpc(ctx Context, rpc Rpc) (any, error)
- func Fatal(message string, v ...any)
- func GetTableName(model any) (tableName string)
- func GetValidRpcReturnNameDecl(pType RpcReturnDataType, returnAlias bool) (string, error)
- func Info(message string, v ...any)
- func MarshalRpcParamTag(paramTag *RpcParamTag) (string, error)
- func MarshallAndValidate(ctx *fasthttp.RequestCtx, controller any) error
- func NewGracefulListener(ln net.Listener, maxWaitTime time.Duration) net.Listener
- func NewRouter(config *Config) *router
- func Panic(message string)
- func RealtimeBroadcastHandler(ctx *fasthttp.RequestCtx, u *url.URL)
- func RestProxy(appCtx Context, TableName string) error
- func RpcParamToGoType(dataType RpcParamDataType) string
- func RpcReturnToGoType(dataType RpcReturnDataType) string
- func SetLogLevel(level hclog.Level)
- func StorageProxy(appCtx Context, bucketName string, routePath string) error
- func Validate(payload any, requestValidators ...ValidatorFunc) error
- func Warning(message string, v ...any)
- func WebSocketHandler(ctx *fasthttp.RequestCtx, u *url.URL)
- type Acl
- type AclTag
- type Bucket
- type BucketBase
- type Chain
- type ColumnTag
- type Config
- type Context
- type Controller
- type ControllerBase
- func (*ControllerBase) AfterAll(ctx Context) error
- func (*ControllerBase) AfterDelete(ctx Context) error
- func (*ControllerBase) AfterGet(ctx Context) error
- func (*ControllerBase) AfterHead(ctx Context) error
- func (*ControllerBase) AfterOptions(ctx Context) error
- func (*ControllerBase) AfterPatch(ctx Context) error
- func (*ControllerBase) AfterPost(ctx Context) error
- func (*ControllerBase) AfterPut(ctx Context) error
- func (*ControllerBase) BeforeAll(ctx Context) error
- func (*ControllerBase) BeforeDelete(ctx Context) error
- func (*ControllerBase) BeforeGet(ctx Context) error
- func (*ControllerBase) BeforeHead(ctx Context) error
- func (*ControllerBase) BeforeOptions(ctx Context) error
- func (*ControllerBase) BeforePatch(ctx Context) error
- func (*ControllerBase) BeforePost(ctx Context) error
- func (*ControllerBase) BeforePut(ctx Context) error
- func (*ControllerBase) Delete(ctx Context) error
- func (*ControllerBase) Get(ctx Context) error
- func (*ControllerBase) Head(ctx Context) error
- func (*ControllerBase) Options(ctx Context) error
- func (*ControllerBase) Patch(ctx Context) error
- func (*ControllerBase) Post(ctx Context) error
- func (*ControllerBase) Put(ctx Context) error
- type CorsOptions
- type Ctx
- func (c *Ctx) Config() *Config
- func (c *Ctx) Ctx() context.Context
- func (c *Ctx) ExecuteRpc(rpc Rpc) (any, error)
- func (c *Ctx) Get(key string) any
- func (c *Ctx) NewJobCtx() (JobContext, error)
- func (c *Ctx) RequestContext() *fasthttp.RequestCtx
- func (c *Ctx) SendError(message string) error
- func (c *Ctx) SendErrorWithCode(statusCode int, err error) error
- func (c *Ctx) SendJson(data any) error
- func (c *Ctx) SendRpc(rpc Rpc) error
- func (c *Ctx) Set(key string, value any)
- func (c *Ctx) SetCtx(ctx context.Context)
- func (c *Ctx) SetSpan(span trace.Span)
- func (c *Ctx) Span() trace.Span
- func (c *Ctx) Tracer() trace.Tracer
- func (c *Ctx) Write(data []byte)
- func (c *Ctx) WriteError(err error)
- type DeploymentTarget
- type ErrorResponse
- type GracefulListener
- type HealthController
- type HealthRequest
- type HealthResponse
- type Job
- type JobBase
- func (j *JobBase) After(ctx JobContext, jobID uuid.UUID, jobName string)
- func (j *JobBase) AfterErr(ctx JobContext, jobID uuid.UUID, jobName string, err error)
- func (j *JobBase) Before(ctx JobContext, jobID uuid.UUID, jobName string)
- func (j *JobBase) Duration() JobDuration
- func (j *JobBase) Task(ctx JobContext) error
- type JobContext
- type JobData
- type JobDuration
- type JobParams
- type JoinTag
- type MiddlewareFn
- type ModelBase
- type RelationType
- type RestController
- func (rc RestController) AfterAll(ctx Context) error
- func (rc RestController) AfterDelete(ctx Context) error
- func (rc RestController) AfterGet(ctx Context) error
- func (rc RestController) AfterHead(ctx Context) error
- func (rc RestController) AfterOptions(ctx Context) error
- func (rc RestController) AfterPatch(ctx Context) error
- func (rc RestController) AfterPost(ctx Context) error
- func (rc RestController) AfterPut(ctx Context) error
- func (rc RestController) BeforeAll(ctx Context) error
- func (rc RestController) BeforeDelete(ctx Context) error
- func (rc RestController) BeforeGet(ctx Context) error
- func (rc RestController) BeforeHead(ctx Context) error
- func (rc RestController) BeforeOptions(ctx Context) error
- func (rc RestController) BeforePatch(ctx Context) error
- func (rc RestController) BeforePost(ctx Context) error
- func (rc RestController) BeforePut(ctx Context) error
- func (rc RestController) Delete(ctx Context) error
- func (rc RestController) Get(ctx Context) error
- func (rc RestController) Head(ctx Context) error
- func (rc RestController) Options(ctx Context) error
- func (rc RestController) Patch(ctx Context) error
- func (rc RestController) Post(ctx Context) error
- func (rc RestController) Put(ctx Context) error
- type Role
- type RoleBase
- type Route
- type RouteHandlerFn
- type RouteType
- type Rpc
- type RpcBase
- func (r *RpcBase) BindModel(model any, alias string) Rpc
- func (r *RpcBase) BindModels()
- func (r *RpcBase) GetBehavior() RpcBehaviorType
- func (r *RpcBase) GetCompleteStmt() string
- func (r *RpcBase) GetModels() map[string]RpcModel
- func (r *RpcBase) GetName() string
- func (r *RpcBase) GetParams() []RpcParam
- func (r *RpcBase) GetRawDefinition() (d string)
- func (r *RpcBase) GetReturnType() (rt RpcReturnDataType)
- func (r *RpcBase) GetReturnTypeStmt() string
- func (r *RpcBase) GetSchema() string
- func (r *RpcBase) GetSecurity() RpcSecurityType
- func (r *RpcBase) SetBehavior(behavior RpcBehaviorType)
- func (r *RpcBase) SetCompleteStmt(stmt string)
- func (r *RpcBase) SetName(name string)
- func (r *RpcBase) SetParams(params []RpcParam)
- func (r *RpcBase) SetRawDefinition(definition string)
- func (r *RpcBase) SetReturnType(returnType RpcReturnDataType)
- func (r *RpcBase) SetReturnTypeStmt(returnTypeStmt string)
- func (r *RpcBase) SetSchema(schema string)
- func (r *RpcBase) SetSecurity(security RpcSecurityType)
- func (r *RpcBase) UseParamPrefix() bool
- type RpcBehaviorType
- type RpcModel
- type RpcParam
- type RpcParamDataType
- type RpcParamTag
- type RpcParams
- type RpcReturnDataType
- type RpcSecurityType
- type ScheduleStatus
- type Scheduler
- type SchedulerServer
- type Server
- type StorageController
- func (rc StorageController) AfterAll(ctx Context) error
- func (rc StorageController) AfterDelete(ctx Context) error
- func (rc StorageController) AfterGet(ctx Context) error
- func (rc StorageController) AfterHead(ctx Context) error
- func (rc StorageController) AfterOptions(ctx Context) error
- func (rc StorageController) AfterPatch(ctx Context) error
- func (rc StorageController) AfterPost(ctx Context) error
- func (rc StorageController) AfterPut(ctx Context) error
- func (rc StorageController) BeforeAll(ctx Context) error
- func (rc StorageController) BeforeDelete(ctx Context) error
- func (rc StorageController) BeforeGet(ctx Context) error
- func (rc StorageController) BeforeHead(ctx Context) error
- func (rc StorageController) BeforeOptions(ctx Context) error
- func (rc StorageController) BeforePatch(ctx Context) error
- func (rc StorageController) BeforePost(ctx Context) error
- func (rc StorageController) BeforePut(ctx Context) error
- func (rc StorageController) Delete(ctx Context) error
- func (rc StorageController) Get(ctx Context) error
- func (rc StorageController) Head(ctx Context) error
- func (rc StorageController) Options(ctx Context) error
- func (rc StorageController) Patch(ctx Context) error
- func (rc StorageController) Post(ctx Context) error
- func (rc StorageController) Put(ctx Context) error
- type ValidatorFunc
- type WithValidator
Constants ¶
const ( DefaultRoleValidUntilLayout = "2006-01-02" DefaultRoleConnectionLimit = 60 )
const ( RpcBehaviorVolatile RpcBehaviorType = "VOLATILE" RpcBehaviorStable RpcBehaviorType = "STABLE" RpcBehaviorImmutable RpcBehaviorType = "IMMUTABLE" RpcSecurityTypeDefiner RpcSecurityType = "DEFINER" RpcSecurityTypeInvoker RpcSecurityType = "INVOKER" RpcTemplate = `` /* 145-byte string literal not displayed */ )
Variables ¶
var ( DefaultRpcParamPrefix = "in_" DefaultRpcSchema = "public" )
var ControllerLogger = logger.HcLog().Named("raiden.controller")
var MiddlewareLogger = logger.HcLog().Named("raiden.middleware")
var RouterLogger = logger.HcLog().Named("raiden.router")
var RpcLogger = logger.HcLog().Named("raiden.rpc")
var SchedulerLogger = logger.HcLog().Named("raiden.scheduler")
var ServerLogger = logger.HcLog().Named("raiden.server")
Functions ¶
func ConvertRequestCtxToHTTPRequest ¶
func ConvertRequestCtxToHTTPRequest(ctx *fasthttp.RequestCtx) (*http.Request, error)
func CorsMiddleware ¶
func CorsMiddleware(config *Config) fasthttp.RequestHandler
func GetTableName ¶
func GetValidRpcReturnNameDecl ¶
func GetValidRpcReturnNameDecl(pType RpcReturnDataType, returnAlias bool) (string, error)
func MarshalRpcParamTag ¶
func MarshalRpcParamTag(paramTag *RpcParamTag) (string, error)
func MarshallAndValidate ¶
func MarshallAndValidate(ctx *fasthttp.RequestCtx, controller any) error
Marshall request data (path param, query and body data) to Payload data in actual controller
Example :
type Request { Search string `query:"q"` Resource string `path:"resource" validate:"required"` } Controller { raiden.ControllerBase Payload *Request }
Example Request : GET /hello/{resource}?q="some-resource"
base on example above this code will auto marshall data from fasthttp.Request to Request struct and validate all data is appropriate base on validate tag
func NewGracefulListener ¶
NewGracefulListener wraps the given listener into 'graceful shutdown' listener.
func RealtimeBroadcastHandler ¶
func RealtimeBroadcastHandler(ctx *fasthttp.RequestCtx, u *url.URL)
func RpcParamToGoType ¶
func RpcParamToGoType(dataType RpcParamDataType) string
func RpcReturnToGoType ¶
func RpcReturnToGoType(dataType RpcReturnDataType) string
func SetLogLevel ¶
func SetLogLevel(level hclog.Level)
func Validate ¶
func Validate(payload any, requestValidators ...ValidatorFunc) error
validate payload
func WebSocketHandler ¶
func WebSocketHandler(ctx *fasthttp.RequestCtx, u *url.URL)
Types ¶
type AclTag ¶
func UnmarshalAclTag ¶
type BucketBase ¶
type BucketBase struct{}
func (*BucketBase) AllowedMimeTypes ¶
func (b *BucketBase) AllowedMimeTypes() []string
func (*BucketBase) AvifAutoDetection ¶
func (b *BucketBase) AvifAutoDetection() bool
func (*BucketBase) FileSizeLimit ¶
func (b *BucketBase) FileSizeLimit() int
func (*BucketBase) Public ¶
func (b *BucketBase) Public() bool
type Chain ¶
type Chain interface { Append(middlewares ...MiddlewareFn) Chain Prepend(middlewares ...MiddlewareFn) Chain Then(httpMethod string, routeType RouteType, fn Controller) RouteHandlerFn }
Chain defines a chain of middleware.
func NewChain ¶
func NewChain(middlewares ...MiddlewareFn) Chain
This is a modified version of https://github.com/zeromicro/go-zero/blob/master/rest/chain/chain.go New creates a new Chain, memorizing the given list of middleware middlewares. New serves no other function, middlewares are only called upon a call to Then() or ThenFunc().
type ColumnTag ¶
type ColumnTag struct { Name string Type string PrimaryKey bool AutoIncrement bool Nullable bool Default any Unique bool }
definition of column tag, example : column:"name:id;type:bigint;primaryKey;autoIncrement;nullable:false;unique;default:now()"
func UnmarshalColumnTag ¶
type Config ¶
type Config struct { AccessToken string `mapstructure:"ACCESS_TOKEN"` AnonKey string `mapstructure:"ANON_KEY"` BreakerEnable bool `mapstructure:"BREAKER_ENABLE"` CorsAllowedOrigins string `mapstructure:"CORS_ALLOWED_ORIGINS"` CorsAllowedMethods string `mapstructure:"CORS_ALLOWED_METHODS"` CorsAllowedHeaders string `mapstructure:"CORS_ALLOWED_HEADERS"` CorsAllowCredentials bool `mapstructure:"CORS_ALLOWED_CREDENTIALS"` DeploymentTarget DeploymentTarget `mapstructure:"DEPLOYMENT_TARGET"` Environment string `mapstructure:"ENVIRONMENT"` ProjectId string `mapstructure:"PROJECT_ID"` ProjectName string `mapstructure:"PROJECT_NAME"` ServiceKey string `mapstructure:"SERVICE_KEY"` ServerHost string `mapstructure:"SERVER_HOST"` ServerPort string `mapstructure:"SERVER_PORT"` SupabaseApiUrl string `mapstructure:"SUPABASE_API_URL"` SupabaseApiBasePath string `mapstructure:"SUPABASE_API_BASE_PATH"` SupabasePublicUrl string `mapstructure:"SUPABASE_PUBLIC_URL"` ScheduleStatus ScheduleStatus `mapstructure:"SCHEDULE_STATUS"` TraceEnable bool `mapstructure:"TRACE_ENABLE"` TraceCollector string `mapstructure:"TRACE_COLLECTOR"` TraceCollectorEndpoint string `mapstructure:"TRACE_COLLECTOR_ENDPOINT"` Version string `mapstructure:"VERSION"` MaxServerRequestBodySize int `mapstructure:"MAX_SERVER_REQUEST_BODY_SIZE"` }
func LoadConfig ¶
The function `LoadConfig` loads a configuration file based on the provided path or uses default values if no path is provided.
func (*Config) GetFloat64 ¶
func (*Config) GetIntSlice ¶
func (*Config) GetStringSlice ¶
type Context ¶
type Context interface { Ctx() context.Context SetCtx(ctx context.Context) Config() *Config SendRpc(Rpc) error ExecuteRpc(Rpc) (any, error) SendJson(data any) error SendError(message string) error SendErrorWithCode(statusCode int, err error) error RequestContext() *fasthttp.RequestCtx Span() trace.Span SetSpan(span trace.Span) Tracer() trace.Tracer NewJobCtx() (JobContext, error) Write(data []byte) WriteError(err error) Set(key string, value any) Get(key string) any }
The `Context` interface defines a set of methods that can be implemented by a struct to provide a context for handling HTTP requests in the Raiden framework.
type Controller ¶
type Controller interface { BeforeAll(ctx Context) error AfterAll(ctx Context) error AfterGet(ctx Context) error BeforeGet(ctx Context) error Get(ctx Context) error AfterPost(ctx Context) error BeforePost(ctx Context) error Post(ctx Context) error AfterPut(ctx Context) error BeforePut(ctx Context) error Put(ctx Context) error AfterPatch(ctx Context) error BeforePatch(ctx Context) error Patch(ctx Context) error AfterDelete(ctx Context) error BeforeDelete(ctx Context) error Delete(ctx Context) error AfterOptions(ctx Context) error BeforeOptions(ctx Context) error Options(ctx Context) error AfterHead(ctx Context) error BeforeHead(ctx Context) error Head(ctx Context) error }
The `Controller` interface defines a set of methods that a controller in the Raiden framework should implement. These methods correspond to different HTTP methods (GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD) and are used to handle incoming requests and generate responses. Each method has a "Before" and "After" counterpart, which can be used to perform pre-processing and post-processing tasks respectively.
type ControllerBase ¶
type ControllerBase struct{}
The `ControllerBase` struct is a base struct that implements the `Controller` interface. It provides default implementations for all the methods defined in the interface. These default implementations return a `NotImplemented` error, indicating that the corresponding handler method is not implemented in the actual controller. The actual controller can embed the `ControllerBase` struct and override the methods as needed.
func (*ControllerBase) AfterAll ¶
func (*ControllerBase) AfterAll(ctx Context) error
func (*ControllerBase) AfterDelete ¶
func (*ControllerBase) AfterDelete(ctx Context) error
func (*ControllerBase) AfterGet ¶
func (*ControllerBase) AfterGet(ctx Context) error
func (*ControllerBase) AfterHead ¶
func (*ControllerBase) AfterHead(ctx Context) error
func (*ControllerBase) AfterOptions ¶
func (*ControllerBase) AfterOptions(ctx Context) error
func (*ControllerBase) AfterPatch ¶
func (*ControllerBase) AfterPatch(ctx Context) error
func (*ControllerBase) AfterPost ¶
func (*ControllerBase) AfterPost(ctx Context) error
func (*ControllerBase) AfterPut ¶
func (*ControllerBase) AfterPut(ctx Context) error
func (*ControllerBase) BeforeAll ¶
func (*ControllerBase) BeforeAll(ctx Context) error
func (*ControllerBase) BeforeDelete ¶
func (*ControllerBase) BeforeDelete(ctx Context) error
func (*ControllerBase) BeforeGet ¶
func (*ControllerBase) BeforeGet(ctx Context) error
func (*ControllerBase) BeforeHead ¶
func (*ControllerBase) BeforeHead(ctx Context) error
func (*ControllerBase) BeforeOptions ¶
func (*ControllerBase) BeforeOptions(ctx Context) error
func (*ControllerBase) BeforePatch ¶
func (*ControllerBase) BeforePatch(ctx Context) error
func (*ControllerBase) BeforePost ¶
func (*ControllerBase) BeforePost(ctx Context) error
func (*ControllerBase) BeforePut ¶
func (*ControllerBase) BeforePut(ctx Context) error
func (*ControllerBase) Delete ¶
func (*ControllerBase) Delete(ctx Context) error
func (*ControllerBase) Get ¶
func (*ControllerBase) Get(ctx Context) error
func (*ControllerBase) Head ¶
func (*ControllerBase) Head(ctx Context) error
func (*ControllerBase) Options ¶
func (*ControllerBase) Options(ctx Context) error
func (*ControllerBase) Patch ¶
func (*ControllerBase) Patch(ctx Context) error
func (*ControllerBase) Post ¶
func (*ControllerBase) Post(ctx Context) error
func (*ControllerBase) Put ¶
func (*ControllerBase) Put(ctx Context) error
type CorsOptions ¶
type CorsOptions struct { AllowedOrigins []string AllowedMethods []string AllowedHeaders []string AllowCredentials bool OptionsPassthrough bool }
Handle cors
type Ctx ¶
type Ctx struct { context.Context *fasthttp.RequestCtx // contains filtered or unexported fields }
The `Ctx` struct is a struct that implements the `Context` interface in the Raiden framework. It embeds the `context.Context` and `*fasthttp.RequestCtx` types, which provide the context and request information for handling HTTP requests. Additionally, it has fields for storing the configuration (`config`), span (`span`), and tracer (`tracer`) for tracing and monitoring purposes.
func (*Ctx) NewJobCtx ¶
func (c *Ctx) NewJobCtx() (JobContext, error)
func (*Ctx) RequestContext ¶
func (c *Ctx) RequestContext() *fasthttp.RequestCtx
func (*Ctx) SendJson ¶
The `SendJson` function is a method of the `Ctx` struct in the Raiden framework. It is responsible for sending a JSON response to the client.
func (*Ctx) Write ¶
The `Write` function is a method of the `Ctx` struct in the Raiden framework. It is responsible for writing the response body to the HTTP response.
func (*Ctx) WriteError ¶
The `WriteError` function is a method of the `Ctx` struct in the Raiden framework. It is responsible for writing an error response to the HTTP response body.
type DeploymentTarget ¶
type DeploymentTarget string
const ( DeploymentTargetCloud DeploymentTarget = "cloud" DeploymentTargetSelfHosted DeploymentTarget = "self_hosted" )
type ErrorResponse ¶
type ErrorResponse struct { StatusCode int `json:"-"` Code string `json:"code,omitempty"` Details any `json:"details,omitempty"` Hint string `json:"hint,omitempty"` Message string `json:"message"` }
func (*ErrorResponse) Error ¶
func (err *ErrorResponse) Error() string
type GracefulListener ¶
type GracefulListener struct {
// contains filtered or unexported fields
}
--- graceful shutdown listener ----
func (*GracefulListener) Accept ¶
func (ln *GracefulListener) Accept() (net.Conn, error)
Accept creates a conn
func (*GracefulListener) Addr ¶
func (ln *GracefulListener) Addr() net.Addr
Addr returns the listen address
func (*GracefulListener) Close ¶
func (ln *GracefulListener) Close() error
Close closes the inner listener and waits until all the pending open connections are closed before returning.
type HealthController ¶
type HealthController struct { ControllerBase Payload *HealthRequest Result HealthResponse }
func (*HealthController) Get ¶
func (c *HealthController) Get(ctx Context) error
type HealthRequest ¶
type HealthRequest struct{}
type HealthResponse ¶
type HealthResponse struct {
Message string `json:"message"`
}
type Job ¶
type Job interface { Name() string Duration() JobDuration After(ctx JobContext, jobID uuid.UUID, jobName string) AfterErr(ctx JobContext, jobID uuid.UUID, jobName string, err error) Before(ctx JobContext, jobID uuid.UUID, jobName string) Task(ctx JobContext) error }
type JobBase ¶
type JobBase struct{}
func (*JobBase) Duration ¶
func (j *JobBase) Duration() JobDuration
func (*JobBase) Task ¶
func (j *JobBase) Task(ctx JobContext) error
type JobContext ¶
type JobContext interface { context.Context SetContext(c context.Context) Config() *Config RunJob(JobParams) Get(key string) any Set(key string, value any) IsDataExist(key string) bool Span() trace.Span SetSpan(span trace.Span) }
---- Scheduler context
type JoinTag ¶
type JoinTag struct { JoinType RelationType PrimaryKey string ForeignKey string Through string SourcePrimaryKey string SourceForeignKey string TargetPrimaryKey string TargetForeignKey string }
definition of join tag, example: - join:"joinType:hasOne;primaryKey:id;foreignKey:candidate_id" - join:"joinType:hasMany;primaryKey:id;foreignKey:scouter_id" - join:"joinType:manyToMany;through:submission;sourcePrimaryKey:id;sourceForeignKey:candidate_id;targetPrimaryKey:id;targetForeign:candidate_id"
func UnmarshalJoinTag ¶
type MiddlewareFn ¶
type MiddlewareFn func(next RouteHandlerFn) RouteHandlerFn
--- define type and constant ----
func BreakerMiddleware ¶
func BreakerMiddleware(path string) MiddlewareFn
Handler open / close circuit breaker base on request error throttle
type RelationType ¶
type RelationType string
var ( RelationTypeHasOne RelationType = "hasOne" RelationTypeHasMany RelationType = "hasMany" RelationTypeManyToMany RelationType = "manyToMany" )
type RestController ¶
type RestController struct { Controller Model any TableName string }
----- Rest Controller -----
func (RestController) AfterAll ¶
func (rc RestController) AfterAll(ctx Context) error
AfterAll implements Controller. Subtle: this method shadows the method (Controller).AfterAll of RestController.Controller.
func (RestController) AfterDelete ¶
func (rc RestController) AfterDelete(ctx Context) error
AfterDelete implements Controller. Subtle: this method shadows the method (Controller).AfterDelete of RestController.Controller.
func (RestController) AfterGet ¶
func (rc RestController) AfterGet(ctx Context) error
AfterGet implements Controller. Subtle: this method shadows the method (Controller).AfterGet of RestController.Controller.
func (RestController) AfterHead ¶
func (rc RestController) AfterHead(ctx Context) error
AfterHead implements Controller. Subtle: this method shadows the method (Controller).AfterHead of RestController.Controller.
func (RestController) AfterOptions ¶
func (rc RestController) AfterOptions(ctx Context) error
AfterOptions implements Controller. Subtle: this method shadows the method (Controller).AfterOptions of RestController.Controller.
func (RestController) AfterPatch ¶
func (rc RestController) AfterPatch(ctx Context) error
AfterPatch implements Controller. Subtle: this method shadows the method (Controller).AfterPatch of RestController.Controller.
func (RestController) AfterPost ¶
func (rc RestController) AfterPost(ctx Context) error
AfterPost implements Controller. Subtle: this method shadows the method (Controller).AfterPost of RestController.Controller.
func (RestController) AfterPut ¶
func (rc RestController) AfterPut(ctx Context) error
AfterPut implements Controller. Subtle: this method shadows the method (Controller).AfterPut of RestController.Controller.
func (RestController) BeforeAll ¶
func (rc RestController) BeforeAll(ctx Context) error
BeforeAll implements Controller.
func (RestController) BeforeDelete ¶
func (rc RestController) BeforeDelete(ctx Context) error
BeforeDelete implements Controller. Subtle: this method shadows the method (Controller).BeforeDelete of RestController.Controller.
func (RestController) BeforeGet ¶
func (rc RestController) BeforeGet(ctx Context) error
BeforeGet implements Controller. Subtle: this method shadows the method (Controller).BeforeGet of RestController.Controller.
func (RestController) BeforeHead ¶
func (rc RestController) BeforeHead(ctx Context) error
BeforeHead implements Controller. Subtle: this method shadows the method (Controller).BeforeHead of RestController.Controller.
func (RestController) BeforeOptions ¶
func (rc RestController) BeforeOptions(ctx Context) error
BeforeOptions implements Controller. Subtle: this method shadows the method (Controller).BeforeOptions of RestController.Controller.
func (RestController) BeforePatch ¶
func (rc RestController) BeforePatch(ctx Context) error
BeforePatch implements Controller. Subtle: this method shadows the method (Controller).BeforePatch of RestController.Controller.
func (RestController) BeforePost ¶
func (rc RestController) BeforePost(ctx Context) error
BeforePost implements Controller. Subtle: this method shadows the method (Controller).BeforePost of RestController.Controller.
func (RestController) BeforePut ¶
func (rc RestController) BeforePut(ctx Context) error
BeforePut implements Controller. Subtle: this method shadows the method (Controller).BeforePut of RestController.Controller.
func (RestController) Delete ¶
func (rc RestController) Delete(ctx Context) error
Delete implements Controller.
func (RestController) Get ¶
func (rc RestController) Get(ctx Context) error
Get implements Controller.
func (RestController) Head ¶
func (rc RestController) Head(ctx Context) error
Head implements Controller. Subtle: this method shadows the method (Controller).Head of RestController.Controller.
func (RestController) Options ¶
func (rc RestController) Options(ctx Context) error
Options implements Controller. Subtle: this method shadows the method (Controller).Options of RestController.Controller.
func (RestController) Patch ¶
func (rc RestController) Patch(ctx Context) error
Patch implements Controller.
func (RestController) Post ¶
func (rc RestController) Post(ctx Context) error
Post implements Controller.
func (RestController) Put ¶
func (rc RestController) Put(ctx Context) error
Put implements Controller.
type Role ¶
type Role interface { // name Name() string // default 60 ConnectionLimit() int // default true InheritRole() bool // default false CanBypassRls() bool // default false CanCreateDB() bool // default false CanCreateRole() bool // default false CanLogin() bool // default nil ValidUntil() *objects.SupabaseTime }
TODO : support organizational unit roles
type RoleBase ¶
type RoleBase struct { }
TODO : support organizational unit roles
func (*RoleBase) CanBypassRls ¶
func (*RoleBase) CanCreateDB ¶
func (*RoleBase) CanCreateRole ¶
func (*RoleBase) ConnectionLimit ¶
----- Base Role Default Func -----
func (*RoleBase) InheritRole ¶
func (*RoleBase) ValidUntil ¶
func (r *RoleBase) ValidUntil() *objects.SupabaseTime
type Route ¶
type Route struct { Type RouteType Methods []string Path string Controller Controller Model any Storage Bucket }
----- define route type, constant and variable -----
type RouteHandlerFn ¶
----- define route type, constant and variable -----
func TraceMiddleware ¶
func TraceMiddleware(next RouteHandlerFn) RouteHandlerFn
extract trace id and span id from incoming request and create new trace context and span context, inject trace and span context to request context, and set span status
type Rpc ¶
type Rpc interface { BindModels() BindModel(model any, alias string) Rpc GetModels() map[string]RpcModel SetName(name string) GetName() string SetParams(params []RpcParam) GetParams() []RpcParam UseParamPrefix() bool SetSchema(schema string) GetSchema() string SetSecurity(security RpcSecurityType) GetSecurity() RpcSecurityType SetBehavior(behavior RpcBehaviorType) GetBehavior() RpcBehaviorType SetReturnType(returnType RpcReturnDataType) GetReturnType() RpcReturnDataType SetReturnTypeStmt(returnTypeStmt string) GetReturnTypeStmt() string SetRawDefinition(definition string) GetRawDefinition() string SetCompleteStmt(stmt string) GetCompleteStmt() string }
----- Define type, variable and constant -----
type RpcBase ¶
type RpcBase struct { Name string Schema string Params []RpcParam Definition string SecurityType RpcSecurityType ReturnType RpcReturnDataType ReturnTypeStmt string Behavior RpcBehaviorType CompleteStatement string Models map[string]RpcModel }
----- Define type, variable and constant -----
func (*RpcBase) BindModels ¶
func (r *RpcBase) BindModels()
func (*RpcBase) GetBehavior ¶
func (r *RpcBase) GetBehavior() RpcBehaviorType
func (*RpcBase) GetCompleteStmt ¶
func (*RpcBase) GetRawDefinition ¶
func (*RpcBase) GetReturnType ¶
func (r *RpcBase) GetReturnType() (rt RpcReturnDataType)
func (*RpcBase) GetReturnTypeStmt ¶
func (*RpcBase) GetSecurity ¶
func (r *RpcBase) GetSecurity() RpcSecurityType
func (*RpcBase) SetBehavior ¶
func (r *RpcBase) SetBehavior(behavior RpcBehaviorType)
func (*RpcBase) SetCompleteStmt ¶
func (*RpcBase) SetRawDefinition ¶
func (*RpcBase) SetReturnType ¶
func (r *RpcBase) SetReturnType(returnType RpcReturnDataType)
func (*RpcBase) SetReturnTypeStmt ¶
func (*RpcBase) SetSecurity ¶
func (r *RpcBase) SetSecurity(security RpcSecurityType)
func (*RpcBase) UseParamPrefix ¶
type RpcParam ¶
type RpcParam struct { Name string Type RpcParamDataType Default *string Value any }
----- Define type, variable and constant -----
type RpcParamDataType ¶
type RpcParamDataType string
---- Define rpc data type -----
const ( RpcParamDataTypeInteger RpcParamDataType = "INTEGER" RpcParamDataTypeNumeric RpcParamDataType = "NUMERIC" RpcParamDataTypeBigInt RpcParamDataType = "BIGINT" RpcParamDataTypeReal RpcParamDataType = "REAL" RpcParamDataTypeDoublePreci RpcParamDataType = "DOUBLE PRECISION" RpcParamDataTypeText RpcParamDataType = "TEXT" RpcParamDataTypeVarchar RpcParamDataType = "CHARACTER VARYING" RpcParamDataTypeVarcharAlias RpcParamDataType = "VARCHAR" RpcParamDataTypeBoolean RpcParamDataType = "BOOLEAN" RpcParamDataTypeBytea RpcParamDataType = "BYTEA" RpcParamDataTypeTimestamp RpcParamDataType = "TIMESTAMP WITHOUT TIME ZONE" RpcParamDataTypeTimestampAlias RpcParamDataType = "TIMESTAMP" RpcParamDataTypeTimestampTZ RpcParamDataType = "TIMESTAMP WITH TIME ZONE" RpcParamDataTypeTimestampTZAlias RpcParamDataType = "TIMESTAMPZ" RpcParamDataTypeJSON RpcParamDataType = "JSON" RpcParamDataTypeJSONB RpcParamDataType = "JSONB" RpcParamDataTypeUuid RpcParamDataType = "UUID" )
Define constants for rpc input data type
func GetValidRpcParamType ¶
func GetValidRpcParamType(pType string, returnAlias bool) (RpcParamDataType, error)
type RpcParamTag ¶
----- Define type, variable and constant -----
func UnmarshalRpcParamTag ¶
func UnmarshalRpcParamTag(tag string) (RpcParamTag, error)
type RpcReturnDataType ¶
type RpcReturnDataType string
const ( RpcReturnDataTypeInteger RpcReturnDataType = "INTEGER" RpcReturnDataTypeBigInt RpcReturnDataType = "BIGINT" RpcReturnDataTypeReal RpcReturnDataType = "REAL" RpcReturnDataTypeDoublePreci RpcReturnDataType = "DOUBLE PRECISION" RpcReturnDataTypeText RpcReturnDataType = "TEXT" RpcReturnDataTypeVarchar RpcReturnDataType = "CHARACTER VARYING" RpcReturnDataTypeVarcharAlias RpcReturnDataType = "VARCHAR" RpcReturnDataTypeBoolean RpcReturnDataType = "BOOLEAN" RpcReturnDataTypeBytea RpcReturnDataType = "BYTEA" RpcReturnDataTypeTimestamp RpcReturnDataType = "TIMESTAMP WITHOUT TIME ZONE" RpcReturnDataTypeTimestampAlias RpcReturnDataType = "TIMESTAMP" RpcReturnDataTypeTimestampTZ RpcReturnDataType = "TIMESTAMP WITH TIME ZONE" RpcReturnDataTypeTimestampTZAlias RpcReturnDataType = "TIMESTAMPZ" RpcReturnDataTypeJSON RpcReturnDataType = "JSON" RpcReturnDataTypeJSONB RpcReturnDataType = "JSONB" RpcReturnDataTypeRecord RpcReturnDataType = "RECORD" // like tuple RpcReturnDataTypeTable RpcReturnDataType = "TABLE" RpcReturnDataTypeSetOf RpcReturnDataType = "SETOF" RpcReturnDataTypeVoid RpcReturnDataType = "VOID" RpcReturnDataTypeTrigger RpcReturnDataType = "TRIGGER" )
Define constants for rpc return data type
func GetValidRpcReturnType ¶
func GetValidRpcReturnType(pType string, returnAlias bool) (RpcReturnDataType, error)
type ScheduleStatus ¶
type ScheduleStatus string
----- Custom Type
const ( ScheduleStatusOn ScheduleStatus = "on" ScheduleStatusOff ScheduleStatus = "off" )
type Scheduler ¶
type Scheduler interface { RegisterJob(job Job) error Start() Stop(ctx context.Context) error ListenJobChan() SetTracer(tracer trace.Tracer) }
----- Scheduler server
type SchedulerServer ¶
type SchedulerServer struct { Config *Config Server gocron.Scheduler JobChan chan JobParams // contains filtered or unexported fields }
func NewSchedulerServer ¶
func NewSchedulerServer(config *Config, options ...gocron.SchedulerOption) (*SchedulerServer, error)
func (*SchedulerServer) ListenJobChan ¶
func (s *SchedulerServer) ListenJobChan()
func (*SchedulerServer) RegisterJob ¶
func (s *SchedulerServer) RegisterJob(job Job) error
func (*SchedulerServer) SetTracer ¶
func (s *SchedulerServer) SetTracer(tracer trace.Tracer)
func (SchedulerServer) Start ¶
func (s SchedulerServer) Start()
type Server ¶
type Server struct { Config *Config Router *router HttpServer *fasthttp.Server SchedulerServer Scheduler ShutdownFunc []func(ctx context.Context) error // contains filtered or unexported fields }
--- server configuration ----
func (*Server) RegisterJobs ¶
func (*Server) RegisterRoute ¶
func (*Server) Use ¶
func (s *Server) Use(middleware MiddlewareFn)
type StorageController ¶
type StorageController struct { Controller BucketName string RoutePath string }
----- Storage Controller -----
func (StorageController) AfterAll ¶
func (rc StorageController) AfterAll(ctx Context) error
AfterAll implements Controller. Subtle: this method shadows the method (Controller).AfterAll of RestController.Controller.
func (StorageController) AfterDelete ¶
func (rc StorageController) AfterDelete(ctx Context) error
AfterDelete implements Controller. Subtle: this method shadows the method (Controller).AfterDelete of StorageController.Controller.
func (StorageController) AfterGet ¶
func (rc StorageController) AfterGet(ctx Context) error
AfterGet implements Controller. Subtle: this method shadows the method (Controller).AfterGet of StorageController.Controller.
func (StorageController) AfterHead ¶
func (rc StorageController) AfterHead(ctx Context) error
AfterHead implements Controller. Subtle: this method shadows the method (Controller).AfterHead of StorageController.Controller.
func (StorageController) AfterOptions ¶
func (rc StorageController) AfterOptions(ctx Context) error
AfterOptions implements Controller. Subtle: this method shadows the method (Controller).AfterOptions of StorageController.Controller.
func (StorageController) AfterPatch ¶
func (rc StorageController) AfterPatch(ctx Context) error
AfterPatch implements Controller. Subtle: this method shadows the method (Controller).AfterPatch of StorageController.Controller.
func (StorageController) AfterPost ¶
func (rc StorageController) AfterPost(ctx Context) error
AfterPost implements Controller. Subtle: this method shadows the method (Controller).AfterPost of StorageController.Controller.
func (StorageController) AfterPut ¶
func (rc StorageController) AfterPut(ctx Context) error
AfterPut implements Controller. Subtle: this method shadows the method (Controller).AfterPut of StorageController.Controller.
func (StorageController) BeforeAll ¶
func (rc StorageController) BeforeAll(ctx Context) error
BeforeAll implements Controller.
func (StorageController) BeforeDelete ¶
func (rc StorageController) BeforeDelete(ctx Context) error
BeforeDelete implements Controller. Subtle: this method shadows the method (Controller).BeforeDelete of StorageController.Controller.
func (StorageController) BeforeGet ¶
func (rc StorageController) BeforeGet(ctx Context) error
BeforeGet implements Controller. Subtle: this method shadows the method (Controller).BeforeGet of StorageController.Controller.
func (StorageController) BeforeHead ¶
func (rc StorageController) BeforeHead(ctx Context) error
BeforeHead implements Controller. Subtle: this method shadows the method (Controller).BeforeHead of StorageController.Controller.
func (StorageController) BeforeOptions ¶
func (rc StorageController) BeforeOptions(ctx Context) error
BeforeOptions implements Controller. Subtle: this method shadows the method (Controller).BeforeOptions of StorageController.Controller.
func (StorageController) BeforePatch ¶
func (rc StorageController) BeforePatch(ctx Context) error
BeforePatch implements Controller. Subtle: this method shadows the method (Controller).BeforePatch of StorageController.Controller.
func (StorageController) BeforePost ¶
func (rc StorageController) BeforePost(ctx Context) error
BeforePost implements Controller. Subtle: this method shadows the method (Controller).BeforePost of StorageController.Controller.
func (StorageController) BeforePut ¶
func (rc StorageController) BeforePut(ctx Context) error
BeforePut implements Controller. Subtle: this method shadows the method (Controller).BeforePut of StorageController.Controller.
func (StorageController) Delete ¶
func (rc StorageController) Delete(ctx Context) error
Delete implements Controller.
func (StorageController) Get ¶
func (rc StorageController) Get(ctx Context) error
Get implements Controller.
func (StorageController) Head ¶
func (rc StorageController) Head(ctx Context) error
Head implements Controller. Subtle: this method shadows the method (Controller).Head of StorageController.Controller.
func (StorageController) Options ¶
func (rc StorageController) Options(ctx Context) error
Options implements Controller. Subtle: this method shadows the method (Controller).Options of StorageController.Controller.
func (StorageController) Patch ¶
func (rc StorageController) Patch(ctx Context) error
Patch implements Controller.
func (StorageController) Post ¶
func (rc StorageController) Post(ctx Context) error
Post implements Controller.
func (StorageController) Put ¶
func (rc StorageController) Put(ctx Context) error
Put implements Controller.
type ValidatorFunc ¶
type ValidatorFunc struct { Name string Validator validator.Func }
custom struct for validation function
type WithValidator ¶
type WithValidator func(name string, validateFn validator.Func) ValidatorFunc
custom type for custom validation function