Documentation
¶
Index ¶
- Constants
- Variables
- type Application
- func (a *Application) Any(path string, handler HandlerFunc) []*Route
- func (a *Application) Container() *Container
- func (a *Application) Delete(path string, handler HandlerFunc) *Route
- func (a *Application) Get(path string, handler HandlerFunc) *Route
- func (a *Application) Group(prefix string, fn func(r *Router)) *Router
- func (a *Application) Options(path string, handler HandlerFunc) *Route
- func (a *Application) Patch(path string, handler HandlerFunc) *Route
- func (a *Application) Post(path string, handler HandlerFunc) *Route
- func (a *Application) Put(path string, handler HandlerFunc) *Route
- func (a *Application) Router() *Router
- func (a *Application) Run(addr string) error
- func (a *Application) Use(middleware ...MiddlewareFunc)
- type Config
- type Container
- func (c *Container) Alias(alias, abstract string)
- func (c *Container) Bind(abstract string, resolver func(*Container) interface{})
- func (c *Container) Bound(abstract string) bool
- func (c *Container) Call(fn interface{}, params ...interface{}) ([]interface{}, error)
- func (c *Container) Flush()
- func (c *Container) Forget(abstract string)
- func (c *Container) Instance(abstract string, instance interface{})
- func (c *Container) Make(abstract string) (interface{}, error)
- func (c *Container) MustMake(abstract string) interface{}
- func (c *Container) RegisterProvider(provider ServiceProvider, app *Application) error
- func (c *Container) Resolve(target interface{}) error
- func (c *Container) Singleton(abstract string, resolver func(*Container) interface{})
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithJSON(code int, data interface{}) error
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) App() *Application
- func (c *Context) Bind(v interface{}) error
- func (c *Context) Container() *Container
- func (c *Context) Cookie(name, value string, maxAge ...int) *Context
- func (c *Context) Error(message string, code ...int) error
- func (c *Context) FastHTTP() *fasthttp.RequestCtx
- func (c *Context) File(name string) (*multipart.FileHeader, error)
- func (c *Context) FormValue(name string) string
- func (c *Context) Get(key string) interface{}
- func (c *Context) GetCookie(name string) string
- func (c *Context) GetString(key string) string
- func (c *Context) HTML(html string) error
- func (c *Context) Header(name string) string
- func (c *Context) IP() string
- func (c *Context) Input(name string) interface{}
- func (c *Context) JSON(data interface{}) error
- func (c *Context) Method() string
- func (c *Context) MustGet(key string) interface{}
- func (c *Context) Param(name string) string
- func (c *Context) Path() string
- func (c *Context) Query(name string) string
- func (c *Context) QueryDefault(name, defaultValue string) string
- func (c *Context) Redirect(url string, statusCode ...int) error
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetHeader(key, value string) *Context
- func (c *Context) Status(code int) *Context
- func (c *Context) String(format string, values ...interface{}) error
- func (c *Context) Success(data interface{}, message ...string) error
- func (c *Context) Validate(rules map[string]string) error
- func (c *Context) ValidateJSON(rules map[string][]string) (*Validator, error)
- func (c *Context) ValidateRequest(rules map[string][]string) error
- type DB
- type DatabaseConfig
- type HandlerFunc
- type Map
- type MiddlewareFunc
- func AuthMiddleware() MiddlewareFunc
- func CORSMiddleware(allowedOrigins ...string) MiddlewareFunc
- func CompressionMiddleware() MiddlewareFunc
- func GuestMiddleware() MiddlewareFunc
- func JSONOnlyMiddleware() MiddlewareFunc
- func LoggerMiddleware() MiddlewareFunc
- func RateLimitMiddleware(requestsPerMinute int) MiddlewareFunc
- func RecoveryMiddleware() MiddlewareFunc
- func RequestIDMiddleware() MiddlewareFunc
- func SecureHeadersMiddleware() MiddlewareFunc
- func TrimTrailingSlashMiddleware() MiddlewareFunc
- type Migration
- type Migrator
- type Model
- type QueryBuilder
- func (qb *QueryBuilder) Count() (int64, error)
- func (qb *QueryBuilder) Delete() (int64, error)
- func (qb *QueryBuilder) First(dest interface{}) error
- func (qb *QueryBuilder) Get(dest interface{}) error
- func (qb *QueryBuilder) Insert(data Map) (int64, error)
- func (qb *QueryBuilder) Join(table, condition string) *QueryBuilder
- func (qb *QueryBuilder) LeftJoin(table, condition string) *QueryBuilder
- func (qb *QueryBuilder) Limit(limit int) *QueryBuilder
- func (qb *QueryBuilder) Offset(offset int) *QueryBuilder
- func (qb *QueryBuilder) OrWhere(column string, operator string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) OrderBy(column string, direction ...string) *QueryBuilder
- func (qb *QueryBuilder) Select(columns ...string) *QueryBuilder
- func (qb *QueryBuilder) Update(data Map) (int64, error)
- func (qb *QueryBuilder) Where(column string, operator string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) WhereIn(column string, values []interface{}) *QueryBuilder
- type Route
- type Router
- func (r *Router) Add(method, path string, handler HandlerFunc) *Route
- func (r *Router) Delete(path string, handler HandlerFunc) *Route
- func (r *Router) Get(path string, handler HandlerFunc) *Route
- func (r *Router) Group(prefix string, fn func(router *Router)) *Router
- func (r *Router) Handle(ctx *Context) error
- func (r *Router) Middleware(middleware ...MiddlewareFunc) *Router
- func (r *Router) Options(path string, handler HandlerFunc) *Route
- func (r *Router) Patch(path string, handler HandlerFunc) *Route
- func (r *Router) Post(path string, handler HandlerFunc) *Route
- func (r *Router) Put(path string, handler HandlerFunc) *Route
- func (r *Router) Resource(name string, controller interface{})
- type ServiceProvider
- type Validator
Constants ¶
const ( ColorReset = "\033[0m" ColorRed = "\033[31m" ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorBlue = "\033[34m" ColorCyan = "\033[36m" ColorWhite = "\033[37m" ColorGray = "\033[90m" )
ANSI color codes
Variables ¶
var Version = "dev"
Version of the framework (set by build flags)
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is the main framework instance
func NewApplication ¶
func NewApplication(config *Config) *Application
NewApplication creates a new framework instance
func (*Application) Any ¶
func (a *Application) Any(path string, handler HandlerFunc) []*Route
Any registers a route for all HTTP methods
func (*Application) Container ¶
func (a *Application) Container() *Container
Container returns the service container
func (*Application) Delete ¶
func (a *Application) Delete(path string, handler HandlerFunc) *Route
func (*Application) Get ¶
func (a *Application) Get(path string, handler HandlerFunc) *Route
Route registration helpers
func (*Application) Group ¶
func (a *Application) Group(prefix string, fn func(r *Router)) *Router
Group creates a route group with shared middleware/prefix
func (*Application) Options ¶
func (a *Application) Options(path string, handler HandlerFunc) *Route
func (*Application) Patch ¶
func (a *Application) Patch(path string, handler HandlerFunc) *Route
func (*Application) Post ¶
func (a *Application) Post(path string, handler HandlerFunc) *Route
func (*Application) Put ¶
func (a *Application) Put(path string, handler HandlerFunc) *Route
func (*Application) Router ¶
func (a *Application) Router() *Router
Router returns the router instance
func (*Application) Use ¶
func (a *Application) Use(middleware ...MiddlewareFunc)
Use adds global middleware
type Config ¶
type Config struct {
AppName string
Environment string
Debug bool
Port string
Database DatabaseConfig
DatabaseURL string
}
Config structure
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is the dependency injection container
func (*Container) RegisterProvider ¶
func (c *Container) RegisterProvider(provider ServiceProvider, app *Application) error
RegisterProvider registers a service provider
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context wraps fasthttp context with helper methods
func NewContext ¶
func NewContext(ctx *fasthttp.RequestCtx, app *Application) *Context
NewContext creates a new context instance
func (*Context) AbortWithJSON ¶
AbortWithJSON stops execution and returns JSON
func (*Context) AbortWithStatus ¶
AbortWithStatus stops execution and sets status code
func (*Context) FastHTTP ¶
func (c *Context) FastHTTP() *fasthttp.RequestCtx
FastHTTP returns the underlying fasthttp context
func (*Context) File ¶
func (c *Context) File(name string) (*multipart.FileHeader, error)
File gets uploaded file
func (*Context) QueryDefault ¶
QueryDefault gets a query parameter with default value
func (*Context) ValidateJSON ¶
Context validation helper
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a database connection
func (*DB) Table ¶
func (db *DB) Table(table string) *QueryBuilder
Table starts a new query builder for a table
type DatabaseConfig ¶
type HandlerFunc ¶
HandlerFunc is the function signature for route handlers
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc wraps a handler with middleware functionality
func CORSMiddleware ¶
func CORSMiddleware(allowedOrigins ...string) MiddlewareFunc
CORSMiddleware handles CORS headers
func CompressionMiddleware ¶
func CompressionMiddleware() MiddlewareFunc
CompressionMiddleware enables gzip compression
func GuestMiddleware ¶
func GuestMiddleware() MiddlewareFunc
GuestMiddleware ensures user is NOT authenticated
func JSONOnlyMiddleware ¶
func JSONOnlyMiddleware() MiddlewareFunc
JSONOnlyMiddleware ensures requests are JSON
func LoggerMiddleware ¶
func LoggerMiddleware() MiddlewareFunc
LoggerMiddleware logs incoming requests with colors and file logging
func RateLimitMiddleware ¶
func RateLimitMiddleware(requestsPerMinute int) MiddlewareFunc
RateLimitMiddleware implements rate limiting
func RecoveryMiddleware ¶
func RecoveryMiddleware() MiddlewareFunc
RecoveryMiddleware recovers from panics
func RequestIDMiddleware ¶
func RequestIDMiddleware() MiddlewareFunc
RequestIDMiddleware adds a unique request ID
func SecureHeadersMiddleware ¶
func SecureHeadersMiddleware() MiddlewareFunc
SecureHeadersMiddleware adds security headers
func TrimTrailingSlashMiddleware ¶
func TrimTrailingSlashMiddleware() MiddlewareFunc
TrimTrailingSlashMiddleware removes trailing slashes from URLs
type Migrator ¶ added in v1.4.0
type Migrator struct {
// contains filtered or unexported fields
}
Migrator handles database migrations
func NewMigrator ¶ added in v1.4.0
NewMigrator creates a new migrator instance
type Model ¶
type Model struct {
ID int64 `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
Model represents a base model with common fields
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder provides a fluent interface for building queries
func (*QueryBuilder) Count ¶
func (qb *QueryBuilder) Count() (int64, error)
Count returns the count of rows
func (*QueryBuilder) Delete ¶
func (qb *QueryBuilder) Delete() (int64, error)
Delete deletes records
func (*QueryBuilder) First ¶
func (qb *QueryBuilder) First(dest interface{}) error
First executes the query and returns the first row
func (*QueryBuilder) Get ¶
func (qb *QueryBuilder) Get(dest interface{}) error
Get executes the query and returns all rows
func (*QueryBuilder) Insert ¶
func (qb *QueryBuilder) Insert(data Map) (int64, error)
Insert inserts a new record
func (*QueryBuilder) Join ¶
func (qb *QueryBuilder) Join(table, condition string) *QueryBuilder
Join adds a JOIN clause
func (*QueryBuilder) LeftJoin ¶
func (qb *QueryBuilder) LeftJoin(table, condition string) *QueryBuilder
LeftJoin adds a LEFT JOIN clause
func (*QueryBuilder) Limit ¶
func (qb *QueryBuilder) Limit(limit int) *QueryBuilder
Limit sets the LIMIT clause
func (*QueryBuilder) Offset ¶
func (qb *QueryBuilder) Offset(offset int) *QueryBuilder
Offset sets the OFFSET clause
func (*QueryBuilder) OrWhere ¶
func (qb *QueryBuilder) OrWhere(column string, operator string, value interface{}) *QueryBuilder
OrWhere adds an OR WHERE clause
func (*QueryBuilder) OrderBy ¶
func (qb *QueryBuilder) OrderBy(column string, direction ...string) *QueryBuilder
OrderBy adds ORDER BY clause
func (*QueryBuilder) Select ¶
func (qb *QueryBuilder) Select(columns ...string) *QueryBuilder
Select specifies columns to select
func (*QueryBuilder) Update ¶
func (qb *QueryBuilder) Update(data Map) (int64, error)
Update updates records
func (*QueryBuilder) Where ¶
func (qb *QueryBuilder) Where(column string, operator string, value interface{}) *QueryBuilder
Where adds a WHERE clause
func (*QueryBuilder) WhereIn ¶
func (qb *QueryBuilder) WhereIn(column string, values []interface{}) *QueryBuilder
WhereIn adds a WHERE IN clause
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route represents a single route definition
func (*Route) Middleware ¶
func (route *Route) Middleware(middleware ...MiddlewareFunc) *Route
Middleware adds middleware to this specific route
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router manages application routes
func (*Router) Add ¶
func (r *Router) Add(method, path string, handler HandlerFunc) *Route
Add registers a new route
func (*Router) Get ¶
func (r *Router) Get(path string, handler HandlerFunc) *Route
Route registration methods
func (*Router) Middleware ¶
func (r *Router) Middleware(middleware ...MiddlewareFunc) *Router
Middleware adds middleware to the router group
type ServiceProvider ¶
type ServiceProvider interface {
Register(*Container)
Boot(*Application) error
}
ServiceProvider interface for registering services
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator handles request validation
func NewValidator ¶
NewValidator creates a new validator instance
func (*Validator) FirstError ¶
FirstError returns the first error message