Documentation
¶
Index ¶
- Constants
- Variables
- func BootService(bootstrapper func(a App) error)
- func RegisterService(registrar func(a App) error)
- type App
- type AppCore
- type AppEngine
- type Application
- func (a *Application) AddCommands(commands []Command)
- func (a *Application) AddService(serviceType interface{})
- func (a *Application) Config() config.Configuration
- func (a *Application) HandleSignals(srv *http.Server)
- func (a *Application) Router() Router
- func (a *Application) Run()
- func (a *Application) RunningInConsole() bool
- func (a *Application) Service(serviceType interface{}) error
- func (a *Application) WithCommands(commands []Command) Bootstrapper
- func (a *Application) WithConfig(c config.M) Bootstrapper
- func (a *Application) WithRoutes(routeCallback RouteCallback) Bootstrapper
- type BaseInput
- type Bootstrapper
- type Command
- type Context
- func (c *Context) Alert(typ string, message string) *res.AlertMessage
- func (c *Context) App() App
- func (c *Context) AuthUser() interface{}
- func (c *Context) Back() error
- func (c *Context) BadRequest(err error) error
- func (c *Context) Body() (map[string][]string, error)
- func (c *Context) Cookie(name string) *http.Cookie
- func (c *Context) DecodeJSON(v interface{}) error
- func (c *Context) Download(path string, filename string) error
- func (c *Context) Error(status int, err error) error
- func (c *Context) File(path string, headers ...map[string][]string) error
- func (c *Context) Forbidden(err error) error
- func (c *Context) Form() (map[string][]string, error)
- func (c *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (c *Context) Get(key string) any
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetInput() any
- func (c *Context) GetSession(key string) any
- func (c *Context) GetSessionString(key string) string
- func (c *Context) HTML(body []byte) error
- func (c *Context) HasFile(key string) bool
- func (c *Context) HasFormURLEncodedRequest() bool
- func (c *Context) HasMultiPartRequest() bool
- func (c *Context) Inertia(filePath string, props map[string]any) error
- func (c *Context) Input(inputStruct any) any
- func (c *Context) InternalServerError(err error) error
- func (c *Context) IsInertiaRequest() bool
- func (c *Context) IsReading() bool
- func (c *Context) JSON(body M) error
- func (c *Context) Next() error
- func (c *Context) NoContent() error
- func (c *Context) NotFound(err error) error
- func (c *Context) PageExpired() error
- func (c *Context) Param(key string) string
- func (c *Context) ParseInput(inputStruct any) error
- func (c *Context) PopSession(key string) any
- func (c *Context) PopSessionString(key string) string
- func (c *Context) PutSession(key string, value any) *Context
- func (c *Context) Query(key string) string
- func (c *Context) Redirect(url string) error
- func (c *Context) Referer() string
- func (c *Context) Render(tmplPath string, data *res.TemplateData) error
- func (c *Context) Request() *http.Request
- func (c *Context) RequestContext() context.Context
- func (c *Context) Respond(r *R) error
- func (c *Context) ResponseWriter() http.ResponseWriter
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetCookie(name string, value string, maxAge int, path string, domain string, secure bool, ...)
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) SetInput(inputStruct any) error
- func (c *Context) SetRequest(r *http.Request)
- func (c *Context) Status(status int) *Context
- func (c *Context) StorageFile(path string, headers ...map[string][]string) error
- func (c *Context) Templ(component templ.Component) error
- func (c *Context) Text(body []byte) error
- func (c *Context) Unauthorized(err error) error
- func (c *Context) Upload(uploadedFileName string, dir string, filename ...string) (*os.File, error)
- func (c *Context) Validate(body req.Validator) error
- func (c *Context) ValidationError(err error) error
- func (c *Context) WantsHTML() bool
- func (c *Context) WantsJSON() bool
- func (c *Context) With(key string, message string) *Context
- func (c *Context) WithData(data map[string]any) *Context
- func (c *Context) WithError(message string) *Context
- func (c *Context) WithErrors(errors shared.ValidationErrors) *Context
- func (c *Context) WithInfo(message string) *Context
- func (c *Context) WithInput() *Context
- func (c *Context) WithSuccess(message string) *Context
- func (c *Context) WithWarning(message string) *Context
- type FileInput
- type Group
- func (g *Group) Delete(pattern string, handlers ...Handler) *Route
- func (g *Group) Get(pattern string, handlers ...Handler) *Route
- func (g *Group) Group(prefix string) *Group
- func (g *Group) Patch(pattern string, handlers ...Handler) *Route
- func (g *Group) Post(pattern string, handlers ...Handler) *Route
- func (g *Group) Put(pattern string, handlers ...Handler) *Route
- func (g *Group) UseAfter(handlers ...Handler)
- func (g *Group) UseBefore(handlers ...Handler)
- type HTTPMiddleware
- type HTTPRouter
- func (r *HTTPRouter) Connect(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Delete(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Get(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Group(prefix string) *Group
- func (r *HTTPRouter) Handle(pattern string, handler http.Handler)
- func (r *HTTPRouter) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (r *HTTPRouter) HasRoute(method string, pattern string) bool
- func (r *HTTPRouter) Head(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Options(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Patch(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Post(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Put(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *HTTPRouter) Trace(pattern string, handlers ...Handler) *Route
- func (r *HTTPRouter) Use(middlewares ...HTTPMiddleware)
- func (r *HTTPRouter) UseAfter(handlers ...Handler)
- func (r *HTTPRouter) UseBefore(handlers ...Handler)
- type Handler
- type M
- type Middleware
- type OptFunc
- type Options
- type Publishable
- type R
- type Route
- type RouteCallback
- type Router
- type ServiceContainer
- type ServiceRegistrar
- type VField
- func (f *VField) ActiveURL() *VField
- func (f *VField) AfterDate(afterDate time.Time) *VField
- func (f *VField) Alpha() *VField
- func (f *VField) AlphaDash() *VField
- func (f *VField) AlphaNumeric() *VField
- func (f *VField) Ascii() *VField
- func (f *VField) BeforeDate(beforeDate time.Time) *VField
- func (f *VField) Between(min, max int) *VField
- func (f *VField) Boolean() *VField
- func (f *VField) Contains(substring string) *VField
- func (f *VField) Custom(validateFunc func(v interface{}) (bool, string)) *VField
- func (f *VField) Date(layout string) *VField
- func (f *VField) Dimensions(width, height int) *VField
- func (f *VField) Distinct() *VField
- func (f *VField) Email() *VField
- func (f *VField) EndsWith(suffix string) *VField
- func (f *VField) Equals(value interface{}) *VField
- func (f *VField) Filled() *VField
- func (f *VField) ForEach(rules ...func(*VField) *VField) *VField
- func (f *VField) HexColor() *VField
- func (f *VField) IP() *VField
- func (f *VField) In(validValues []string) *VField
- func (f *VField) JSON() *VField
- func (f *VField) MacAddress() *VField
- func (f *VField) Max(max int) *VField
- func (f *VField) MimeTypes(allowedTypes []string) *VField
- func (f *VField) Min(min int) *VField
- func (f *VField) Name() string
- func (f *VField) Numeric() *VField
- func (f *VField) Regex(pattern string) *VField
- func (f *VField) Required() *VField
- func (f *VField) SetValue(value interface{}) *VField
- func (f *VField) StartsWith(prefix string) *VField
- func (f *VField) Timezone() *VField
- func (f *VField) ULID() *VField
- func (f *VField) URL() *VField
- func (f *VField) UUID() *VField
- func (f *VField) Unique(table string, column string, whereClauses ...map[string]interface{}) *VField
- func (f *VField) Value() interface{}
- type Validator
Constants ¶
const HTTPInKey = "input"
Variables ¶
var (
ErrServiceNotFound = errors.New("service not found")
)
Functions ¶
func BootService ¶
func RegisterService ¶
Types ¶
type App ¶
type App interface { ServiceRegistrar AppCore }
type AppCore ¶
type AppCore interface { Config() config.Configuration Router() Router RunningInConsole() bool AddCommands(commands []Command) }
type AppEngine ¶
type AppEngine interface { Bootstrapper ServiceRegistrar AppCore }
type Application ¶
type Application struct { //*container.Container Services *ServiceContainer // contains filtered or unexported fields }
Application is the main application
func (*Application) AddCommands ¶
func (a *Application) AddCommands(commands []Command)
func (*Application) AddService ¶
func (a *Application) AddService(serviceType interface{})
AddService is a helper method to easily add a service
func (*Application) Config ¶
func (a *Application) Config() config.Configuration
func (*Application) HandleSignals ¶
func (a *Application) HandleSignals(srv *http.Server)
func (*Application) Router ¶
func (a *Application) Router() Router
func (*Application) Run ¶
func (a *Application) Run()
func (*Application) RunningInConsole ¶
func (a *Application) RunningInConsole() bool
func (*Application) Service ¶
func (a *Application) Service(serviceType interface{}) error
Service is a helper method to easily get a service
func (*Application) WithCommands ¶
func (a *Application) WithCommands(commands []Command) Bootstrapper
WithCommands register the commands
func (*Application) WithConfig ¶
func (a *Application) WithConfig(c config.M) Bootstrapper
WithConfig sets the config map to the current config instance
func (*Application) WithRoutes ¶
func (a *Application) WithRoutes(routeCallback RouteCallback) Bootstrapper
WithRoutes calls the provided callback and registers the routes
type Bootstrapper ¶
type Bootstrapper interface { WithConfig(c config.M) Bootstrapper WithCommands(commands []Command) Bootstrapper WithRoutes(routeCallback RouteCallback) Bootstrapper Run() }
type Context ¶
func (*Context) BadRequest ¶
func (*Context) DecodeJSON ¶
func (*Context) GetSession ¶
func (*Context) GetSessionString ¶
func (*Context) HasFormURLEncodedRequest ¶
func (*Context) HasMultiPartRequest ¶
func (*Context) InternalServerError ¶
func (*Context) IsInertiaRequest ¶
func (*Context) PageExpired ¶
func (*Context) ParseInput ¶
func (*Context) PopSession ¶
func (*Context) PopSessionString ¶
func (*Context) RequestContext ¶
func (*Context) ResponseWriter ¶
func (c *Context) ResponseWriter() http.ResponseWriter
func (*Context) SetCookie ¶
func (c *Context) SetCookie(name string, value string, maxAge int, path string, domain string, secure bool, httpOnly bool)
SetCookie sets a cookie on the response writer Example: // c.SetCookie("jwt", token, 60*60*24*7, "/", "", false, true)
func (*Context) SetRequest ¶
func (*Context) StorageFile ¶
func (*Context) Unauthorized ¶
func (*Context) ValidationError ¶
func (*Context) WithErrors ¶
func (c *Context) WithErrors(errors shared.ValidationErrors) *Context
func (*Context) WithSuccess ¶
func (*Context) WithWarning ¶
type HTTPRouter ¶
type HTTPRouter struct {
// contains filtered or unexported fields
}
func (*HTTPRouter) Connect ¶
func (r *HTTPRouter) Connect(pattern string, handlers ...Handler) *Route
func (*HTTPRouter) Group ¶
func (r *HTTPRouter) Group(prefix string) *Group
func (*HTTPRouter) HandleFunc ¶
func (r *HTTPRouter) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
func (*HTTPRouter) Options ¶
func (r *HTTPRouter) Options(pattern string, handlers ...Handler) *Route
func (*HTTPRouter) ServeHTTP ¶
func (r *HTTPRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*HTTPRouter) Use ¶
func (r *HTTPRouter) Use(middlewares ...HTTPMiddleware)
Use adds one or more standard net/http middleware to the router
func (*HTTPRouter) UseAfter ¶
func (r *HTTPRouter) UseAfter(handlers ...Handler)
func (*HTTPRouter) UseBefore ¶
func (r *HTTPRouter) UseBefore(handlers ...Handler)
type Middleware ¶
type OptFunc ¶
type OptFunc func(opts *Options)
func WithCommands ¶
func WithConfig ¶
func WithRoutes ¶
func WithRoutes(routes RouteCallback) OptFunc
type Publishable ¶
func (*Publishable) Publish ¶
func (p *Publishable) Publish() error
type Route ¶
type RouteCallback ¶
type RouteCallback func(r Router)
type Router ¶
type Router interface { Group(prefix string) *Group UseBefore(handlers ...Handler) UseAfter(handlers ...Handler) HasRoute(method string, pattern string) bool Handle(pattern string, handler http.Handler) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) Get(pattern string, handlers ...Handler) *Route Post(pattern string, handlers ...Handler) *Route Put(pattern string, handlers ...Handler) *Route Patch(pattern string, handlers ...Handler) *Route Delete(pattern string, handlers ...Handler) *Route Connect(pattern string, handlers ...Handler) *Route Head(pattern string, handlers ...Handler) *Route Options(pattern string, handlers ...Handler) *Route Trace(pattern string, handlers ...Handler) *Route Use(middlewares ...HTTPMiddleware) }
type ServiceContainer ¶
type ServiceContainer struct {
// contains filtered or unexported fields
}
ServiceContainer holds all the application's dependencies
func (*ServiceContainer) Add ¶
func (sc *ServiceContainer) Add(service interface{})
Add adds a service to the container
func (*ServiceContainer) Get ¶
func (sc *ServiceContainer) Get(service interface{}) error
Get retrieves a service from the container and populates the provided pointer or pointer to pointer
type ServiceRegistrar ¶
type ServiceRegistrar interface { Service(serviceType interface{}) error AddService(serviceType interface{}) }
type VField ¶
type VField struct {
// contains filtered or unexported fields
}
func (*VField) AlphaDash ¶
AlphaDash checks if the string contains only alpha-numeric characters, dashes, or underscores
func (*VField) AlphaNumeric ¶
AlphaNumeric checks if the value contains only alphanumeric characters
func (*VField) BeforeDate ¶
BeforeDate checks if the date is before the specified date
func (*VField) Dimensions ¶
Dimensions checks if the image file has the specified dimensions
func (*VField) Filled ¶
Filled checks if the value is not empty (for strings, slices, maps, and pointers)
func (*VField) MacAddress ¶
MacAddress checks if the string is a valid MAC address
func (*VField) StartsWith ¶
StartsWith checks if the string starts with the specified substring
type Validator ¶
type Validator struct { App Errors shared.ValidationErrors }