Versions in this module Expand all Collapse all v1 v1.1.0 May 1, 2022 v1.0.4 Aug 4, 2020 v1.0.3 Jul 30, 2020 v1.0.2 Feb 11, 2019 v1.0.1 Aug 14, 2018 v1.0.0 Aug 14, 2018 Changes in this version + const CurrentLocaleRenderArg + const MarsImportPath + const SESSION_ID_KEY + const TIMESTAMP_KEY + var AppName = "(not set)" + var AppRoot = "" + var BasePath = "." + var BoolBinder = Binder + var Config = NewEmptyConfig() + var ConfigFile = path.Join("conf", "app.conf") + var CookieDomain = "" + var CookieHttpOnly = false + var CookiePrefix = "MARS" + var CookieSecure = false + var DateFormat string + var DateTimeFormat string + var DefaultValidationKeys map[string]map[int]string + var DevMode = false + var DisableCSRF = false + var DisabledLogger = log.New(ioutil.Discard, "", 0) + var DualStackHTTP = false + var ERROR = log.New(&marsLogs{ ... }, "ERROR ", defaultLoggerFlags) + var ERROR_CLASS = "hasError" + var Filters = []Filter + var FloatBinder = Binder + var Handler = http.HandlerFunc(handle) + var HttpAddr = ":9000" + var HttpSsl = false + var HttpSslCert = "" + var HttpSslKey = "" + var INFO = log.New(&marsLogs{ ... }, "INFO ", defaultLoggerFlags) + var IntBinder = Binder + var KindBinders = make(map[reflect.Kind]Binder) + var MainRouter *Router + var MainTemplateLoader *TemplateLoader + var MainWatcher *Watcher + var MapBinder = Binder + var MaxAge = time.Hour * 24 + var MimeConfig = NewEmptyConfig() + var MimeTypesFile = path.Join("conf", "mime-types.conf") + var NilChain = []Filter + var NilFilter = func(_ *Controller, _ []Filter) + var PointerBinder = Binder + var RoutesFile = path.Join("conf", "routes") + var RunMode = "prod" + var SSLAddr = ":https" + var SecureServer *http.Server + var SelfSignedCert = false + var SelfSignedDomains = "127.0.0.1" + var SelfSignedOrganization = "ACME Inc." + var Server *http.Server + var StringBinder = Binder + var TRACE = DisabledLogger + var TemplateFuncs = map[string]interface + var TimeBinder = Binder + var TimeFormats = []string + var TypeBinders = make(map[reflect.Type]Binder) + var UintBinder = Binder + var ViewsPath = "views" + var WARN = log.New(&marsLogs{ ... }, "WARN ", defaultLoggerFlags) + var WatchFilter = func(c *Controller, fc []Filter) + func ActionInvoker(c *Controller, _ []Filter) + func Asset(name string) ([]byte, error) + func AssetDir(name string) ([]string, error) + func AssetInfo(name string) (os.FileInfo, error) + func AssetNames() []string + func Bind(params *Params, name string, typ reflect.Type) reflect.Value + func BindFile(fileHeader *multipart.FileHeader, typ reflect.Type) reflect.Value + func BindValue(val string, typ reflect.Type) reflect.Value + func CSRFFilter(c *Controller, fc []Filter) + func CompressFilter(c *Controller, fc []Filter) + func ContainsString(list []string, target string) bool + func ContentTypeByFilename(filename string) string + func DirExists(filename string) bool + func Equal(a, b interface{}) bool + func ExecuteTemplate(tmpl ExecutableTemplate, data interface{}) string + func FilterConfiguringFilter(c *Controller, fc []Filter) + func FilterEq(a, b Filter) bool + func FindMethod(recvType reflect.Type, funcVal reflect.Value) *reflect.Method + func FirstNonEmpty(strs ...string) string + func FlashFilter(c *Controller, fc []Filter) + func HttpMethodOverride(c *Controller, fc []Filter) + func I18nFilter(c *Controller, fc []Filter) + func InitDefaults(mode, basePath string) + func InterceptFunc(intc InterceptorFunc, when When, target interface{}) + func InterceptMethod(intc InterceptorMethod, when When) + func InterceptorFilter(c *Controller, fc []Filter) + func Message(locale, message string, args ...interface{}) string + func MessageHTML(locale, key string, args ...interface{}) template.HTML + func MessageLanguages() []string + func MustAsset(name string) []byte + func MustReadLines(filename string) []string + func OnAppShutdown(f func()) + func OnAppStart(f func()) + func PanicFilter(c *Controller, fc []Filter) + func ParamsFilter(c *Controller, fc []Filter) + func ParseKeyValueCookie(val string, cb func(key, val string)) + func ParseParams(params *Params, req *Request) + func ReadLines(filename string) ([]string, error) + func RegisterController(c interface{}, methods []*MethodType) + func ResolveContentType(req *http.Request) string + func ResolveFormat(req *http.Request) string + func RestoreAsset(dir, name string) error + func RestoreAssets(dir, name string) error + func ReverseUrl(args ...interface{}) (template.URL, error) + func RouterFilter(c *Controller, fc []Filter) + func Run() + func SessionFilter(c *Controller, fc []Filter) + func SetAppSecret(secret string) + func SetupRouter() + func SetupViews() + func Sign(message string) string + func Slug(text string) string + func Unbind(output map[string]string, name string, val interface{}) + func ValidationFilter(c *Controller, fc []Filter) + func ValueBinder(f func(value string, typ reflect.Type) reflect.Value) func(*Params, string, reflect.Type) reflect.Value + func Verify(message, sig string) bool + type AcceptLanguage struct + Language string + Quality float32 + type AcceptLanguages []AcceptLanguage + func ResolveAcceptLanguage(req *http.Request) AcceptLanguages + func (al AcceptLanguages) Len() int + func (al AcceptLanguages) Less(i, j int) bool + func (al AcceptLanguages) String() string + func (al AcceptLanguages) Swap(i, j int) + type ActionDefinition struct + Action string + Args map[string]string + Host string + Method string + Star bool + Url string + func (a *ActionDefinition) String() string + type Args map[string]interface + type BinaryResult struct + Delivery ContentDisposition + Length int64 + ModTime time.Time + Name string + Reader io.Reader + func (r *BinaryResult) Apply(req *Request, resp *Response) + type Binder struct + Bind func(params *Params, name string, typ reflect.Type) reflect.Value + Unbind func(output map[string]string, name string, val interface{}) + type CompressResponseWriter struct + func (c *CompressResponseWriter) Close() error + func (c *CompressResponseWriter) DetectCompressionType(req *Request, resp *Response) + func (c *CompressResponseWriter) Write(b []byte) (int, error) + func (c *CompressResponseWriter) WriteHeader(status int) + func (c CompressResponseWriter) CloseNotify() <-chan bool + type ContentDisposition string + var Attachment ContentDisposition = "attachment" + var Inline ContentDisposition = "inline" + type Controller struct + Action string + AppController interface{} + Args Args + Flash Flash + MethodName string + MethodType *MethodType + Name string + Params *Params + RenderArgs Args + Request *Request + Response *Response + Result Result + Session Session + SkipCSRF bool + Type *ControllerType + Validation *Validation + func NewController(req *Request, resp *Response) *Controller + func (c *Controller) FlashParams() + func (c *Controller) Forbidden(msg string, objs ...interface{}) Result + func (c *Controller) Message(message string, args ...interface{}) (value string) + func (c *Controller) MessageHTML(message string, args ...interface{}) template.HTML + func (c *Controller) NotFound(msg string, objs ...interface{}) Result + func (c *Controller) Redirect(val interface{}, args ...interface{}) Result + func (c *Controller) Render(extraRenderArgs ...Args) Result + func (c *Controller) RenderBinary(memfile io.Reader, filename string, delivery ContentDisposition, ...) Result + func (c *Controller) RenderError(err error) Result + func (c *Controller) RenderFile(file *os.File, delivery ContentDisposition) Result + func (c *Controller) RenderHTML(html string) Result + func (c *Controller) RenderJSON(o interface{}) Result + func (c *Controller) RenderJSONP(callback string, o interface{}) Result + func (c *Controller) RenderTemplate(templatePath string) Result + func (c *Controller) RenderText(text string, objs ...interface{}) Result + func (c *Controller) RenderXML(o interface{}) Result + func (c *Controller) SetAction(controllerName, methodName string) error + func (c *Controller) SetCookie(cookie *http.Cookie) + func (c *Controller) Todo() Result + type ControllerType struct + ControllerIndexes [][]int + Methods []*MethodType + Type reflect.Type + func (ct *ControllerType) Method(name string) *MethodType + type DiscerningListener interface + WatchDir func(info os.FileInfo) bool + WatchFile func(basename string) bool + type Email struct + func ValidEmail() Email + func (e Email) DefaultMessage() string + type Error struct + Column int + Description string + Line int + Link string + MetaError string + Path string + SourceLines []string + SourceType string + Stack string + Title string + func (e *Error) ContextSource() []sourceLine + func (e *Error) Error() string + func (e *Error) SetLink(errorLink string) + type ErrorResult struct + Error error + RenderArgs map[string]interface{} + func (r ErrorResult) Apply(req *Request, resp *Response) + type ExecutableTemplate interface + Execute func(io.Writer, interface{}) error + type Field struct + Error *ValidationError + Name string + func NewField(name string, renderArgs map[string]interface{}) *Field + func (f *Field) ErrorClass() string + func (f *Field) Flash() string + func (f *Field) FlashArray() []string + func (f *Field) Id() string + func (f *Field) Value() interface{} + type Filter func(c *Controller, filterChain []Filter) + type FilterConfigurator struct + func FilterAction(methodRef interface{}) FilterConfigurator + func FilterController(controllerInstance interface{}) FilterConfigurator + func (conf FilterConfigurator) Add(f Filter) FilterConfigurator + func (conf FilterConfigurator) Insert(insert Filter, where When, target Filter) FilterConfigurator + func (conf FilterConfigurator) Remove(target Filter) FilterConfigurator + type Flash struct + Data map[string]string + Out map[string]string + func (f Flash) Error(msg string, args ...interface{}) + func (f Flash) Success(msg string, args ...interface{}) + type GoTemplate struct + func (gotmpl GoTemplate) Content() []string + func (gotmpl GoTemplate) Render(wr io.Writer, arg interface{}) error + type InterceptTarget int + const AllControllers + type Interception struct + When When + func (i Interception) Invoke(val reflect.Value) reflect.Value + type InterceptorFunc func(*Controller) Result + type InterceptorMethod interface + type Length struct + N int + func ValidLength(n int) Length + func (s Length) DefaultMessage() string + func (s Length) IsSatisfied(obj interface{}) bool + type Listener interface + Refresh func() *Error + type Match struct + Regexp *regexp.Regexp + func ValidMatch(regex *regexp.Regexp) Match + func (m Match) DefaultMessage() string + func (m Match) IsSatisfied(obj interface{}) bool + type Max struct + Max int + func ValidMax(max int) Max + func (m Max) DefaultMessage() string + func (m Max) IsSatisfied(obj interface{}) bool + type MaxSize struct + Max int + func ValidMaxSize(max int) MaxSize + func (m MaxSize) DefaultMessage() string + func (m MaxSize) IsSatisfied(obj interface{}) bool + type MergedConfig struct + func LoadConfig(confName string) (*MergedConfig, error) + func NewEmptyConfig() *MergedConfig + func (c *MergedConfig) Bool(option string) (result, found bool) + func (c *MergedConfig) BoolDefault(option string, dfault bool) bool + func (c *MergedConfig) HasSection(section string) bool + func (c *MergedConfig) Int(option string) (result int, found bool) + func (c *MergedConfig) IntDefault(option string, dfault int) int + func (c *MergedConfig) Options(prefix string) []string + func (c *MergedConfig) Raw() *config.Config + func (c *MergedConfig) SetOption(name, value string) + func (c *MergedConfig) SetSection(section string) + func (c *MergedConfig) String(option string) (result string, found bool) + func (c *MergedConfig) StringDefault(option, dfault string) string + type MethodArg struct + Name string + Type reflect.Type + type MethodType struct + Args []*MethodArg + Name string + type Min struct + Min int + func ValidMin(min int) Min + func (m Min) DefaultMessage() string + func (m Min) IsSatisfied(obj interface{}) bool + type MinSize struct + Min int + func ValidMinSize(min int) MinSize + func (m MinSize) DefaultMessage() string + func (m MinSize) IsSatisfied(obj interface{}) bool + type Params struct + Files map[string][]*multipart.FileHeader + Fixed url.Values + Form url.Values + Query url.Values + Route url.Values + func (p *Params) Bind(dest interface{}, name string) + type PlaintextErrorResult struct + Error error + func (r PlaintextErrorResult) Apply(req *Request, resp *Response) + type Range struct + func ValidRange(min, max int) Range + func (r Range) DefaultMessage() string + func (r Range) IsSatisfied(obj interface{}) bool + type RedirectToActionResult struct + func (r *RedirectToActionResult) Apply(req *Request, resp *Response) + type RedirectToUrlResult struct + func (r *RedirectToUrlResult) Apply(req *Request, resp *Response) + type RenderHTMLResult struct + func (r RenderHTMLResult) Apply(req *Request, resp *Response) + type RenderJSONResult struct + func (r RenderJSONResult) Apply(req *Request, resp *Response) + type RenderTemplateResult struct + RenderArgs Args + Template Template + func (r *RenderTemplateResult) Apply(req *Request, resp *Response) + type RenderTextResult struct + func (r RenderTextResult) Apply(req *Request, resp *Response) + type RenderXMLResult struct + func (r RenderXMLResult) Apply(req *Request, resp *Response) + type Request struct + AcceptLanguages AcceptLanguages + ContentType string + Format string + Locale string + Websocket *websocket.Conn + func NewRequest(r *http.Request) *Request + type Required struct + func ValidRequired() Required + func (r Required) DefaultMessage() string + func (r Required) IsSatisfied(obj interface{}) bool + type Response struct + ContentType string + Out http.ResponseWriter + Status int + func NewResponse(w http.ResponseWriter) *Response + func (resp *Response) WriteHeader(defaultStatusCode int, defaultContentType string) + type Result interface + Apply func(req *Request, resp *Response) + type Route struct + Action string + ControllerName string + FixedParams []string + Method string + MethodName string + Path string + TreePath string + func NewRoute(method, path, action, fixedArgs, routesPath string, line int) (r *Route) + type RouteMatch struct + Action string + ControllerName string + FixedParams []string + MethodName string + Params map[string][]string + type Router struct + Routes []*Route + Tree *pathtree.Node + func NewRouter(routesPath string) *Router + func (router *Router) Refresh() (err *Error) + func (router *Router) Reverse(action string, argValues map[string]string) *ActionDefinition + func (router *Router) Route(req *http.Request) *RouteMatch + type Session map[string]string + func GetSessionFromCookie(cookie *http.Cookie) Session + func (s Session) Cookie() *http.Cookie + func (s Session) Id() string + func (s Session) SetDefaultExpiration() + func (s Session) SetNoExpiration() + type Static struct + func (c Static) Serve(prefix, filepath string) Result + func (c Static) ServeFresh(prefix, filepath string) Result + type Template interface + Content func() []string + Name func() string + Render func(wr io.Writer, arg interface{}) error + type TemplateLoader struct + func NewTemplateLoader(paths []string) *TemplateLoader + func (loader *TemplateLoader) Refresh() *Error + func (loader *TemplateLoader) Template(name string, funcMaps ...Args) (Template, error) + func (loader *TemplateLoader) WatchDir(info os.FileInfo) bool + func (loader *TemplateLoader) WatchFile(basename string) bool + type Validation struct + Errors []*ValidationError + func (v *Validation) Check(obj interface{}, checks ...Validator) *ValidationResult + func (v *Validation) Clear() + func (v *Validation) Email(str string) *ValidationResult + func (v *Validation) Error(message string, args ...interface{}) *ValidationResult + func (v *Validation) ErrorMap() map[string]*ValidationError + func (v *Validation) HasErrors() bool + func (v *Validation) Keep() + func (v *Validation) Length(obj interface{}, n int) *ValidationResult + func (v *Validation) Match(str string, regex *regexp.Regexp) *ValidationResult + func (v *Validation) Max(n int, max int) *ValidationResult + func (v *Validation) MaxSize(obj interface{}, max int) *ValidationResult + func (v *Validation) Min(n int, min int) *ValidationResult + func (v *Validation) MinSize(obj interface{}, min int) *ValidationResult + func (v *Validation) Range(n, min, max int) *ValidationResult + func (v *Validation) Required(obj interface{}) *ValidationResult + type ValidationError struct + Key string + Message string + func (e *ValidationError) String() string + type ValidationResult struct + Error *ValidationError + Ok bool + func (r *ValidationResult) Key(key string) *ValidationResult + func (r *ValidationResult) Message(message string, args ...interface{}) *ValidationResult + type Validator interface + DefaultMessage func() string + IsSatisfied func(interface{}) bool + type Watcher struct + func NewWatcher() *Watcher + func (w *Watcher) Listen(listener Listener, roots ...string) + func (w *Watcher) Notify() *Error + func (w *Watcher) NotifyWhenUpdated(listener Listener, watcher *fsnotify.Watcher) + type When int + const AFTER + const BEFORE + const FINALLY + const PANIC + type WriteFlusher interface + Flush func() error