rev

package module
v0.0.0-...-9c18437 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2012 License: MIT Imports: 31 Imported by: 0

README

Revel

This is a port of the amazing Play! framework to the Go language.

It is a high productivity web framework.

Check out the web site.

Build Status

Documentation

Index

Constants

View Source
const (
	DEV  = "dev"
	PROD = "prod"
)
View Source
const DefaultFileContentType = "application/octet-stream"

Variables

View Source
var (
	TypeBinders = make(map[reflect.Type]Binder)
	KindBinders = make(map[reflect.Kind]Binder)
)

These are the lookups to find a Binder for any type of data. The most specific binder found will be used (Type before Kind)

View Source
var (
	// App details
	AppName    string // e.g. "sample"
	BasePath   string // e.g. "/Users/robfig/gocode/src/revel/sample"
	AppPath    string // e.g. "/Users/robfig/gocode/src/revel/sample/app"
	ViewsPath  string // e.g. "/Users/robfig/gocode/src/revel/sample/app/views"
	ImportPath string // e.g. "revel/sample"

	Config  *MergedConfig
	RunMode string // DEV or PROD

	// Revel installation details
	RevelPath         string // e.g. "/Users/robfig/gocode/src/revel"
	RevelTemplatePath string // e.g. "/Users/robfig/gocode/src/revel/templates"

	DEFAULT = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)
	TRACE   = DEFAULT
	INFO    = DEFAULT
	WARN    = DEFAULT
	ERROR   = DEFAULT

	// Revel runs every function in this array after init.
	InitHooks []func()
)
View Source
var (
	MainRouter         *Router
	MainTemplateLoader *TemplateLoader
	MainWatcher        *Watcher
)
View Source
var (
	// The functions available for use in the templates.
	Funcs = map[string]interface{}{
		"url": ReverseUrl,
		"eq":  func(a, b interface{}) bool { return a == b },
		"set": func(key string, value interface{}, renderArgs map[string]interface{}) template.HTML {
			renderArgs[key] = value
			return template.HTML("")
		},
		"append": func(key string, value interface{}, renderArgs map[string]interface{}) template.HTML {
			if renderArgs[key] == nil {
				renderArgs[key] = []interface{}{value}
			} else {
				renderArgs[key] = append(renderArgs[key].([]interface{}), value)
			}
			return template.HTML("")
		},
		"field": func(name string, renderArgs map[string]interface{}) *Field {
			value, _ := renderArgs["flash"].(map[string]string)[name]
			err, _ := renderArgs["errors"].(map[string]*ValidationError)[name]
			return &Field{
				Name:  name,
				Value: value,
				Error: err,
			}
		},
		"option": func(f *Field, val, label string) template.HTML {
			selected := ""
			if f.Value == val {
				selected = " selected"
			}
			return template.HTML(fmt.Sprintf(`<option value="%s"%s>%s</option>`,
				html.EscapeString(val), selected, html.EscapeString(label)))
		},
		"radio": func(f *Field, val string) template.HTML {
			checked := ""
			if f.Value == val {
				checked = " checked"
			}
			return template.HTML(fmt.Sprintf(`<input type="radio" name="%s" value="%s"%s>`,
				html.EscapeString(f.Name), html.EscapeString(val), checked))
		},

		"pad": func(str string, width int) template.HTML {
			if len(str) >= width {
				return template.HTML(html.EscapeString(str))
			}
			return template.HTML(html.EscapeString(str) + strings.Repeat("&nbsp;", width-len(str)))
		},
	}
)
View Source
var (
	// Applications can add custom time formats to this array, and they will be
	// automatically attempted when binding a time.Time.
	TimeFormats = []string{"2006-01-02", "2006-01-02 15:04"}
)

Functions

func Bind

func Bind(params *Params, name string, typ reflect.Type) reflect.Value

Parse the value string into a real Go value. Returns 0 values when things can not be parsed.

func BindFile

func BindFile(fileHeader *multipart.FileHeader, typ reflect.Type) reflect.Value

func BindValue

func BindValue(val string, typ reflect.Type) reflect.Value

func CheckInit

func CheckInit()

func ContainsString

func ContainsString(list []string, target string) bool

func ContentTypeByFilename

func ContentTypeByFilename(filename string) string

Returns a MIME content type based on the filename's extension. If no appropriate one is found, returns "application/octet-stream" by default. Additionally, specifies the charset as UTF-8 for text/* types.

func ExecuteTemplate

func ExecuteTemplate(tmpl ExecutableTemplate, data interface{}) string

Execute a template and returns the result as a string.

func FindMethod

func FindMethod(recvType reflect.Type, funcVal *reflect.Value) *reflect.Method

Return the reflect.Method, given a Receiver type and Func value.

func Init

func Init(importPath string, mode string)

func InterceptFunc

func InterceptFunc(intc InterceptorFunc, when InterceptTime, target interface{})

Install a general interceptor. This can be applied to any Controller. It must have the signature of:

func example(c *rev.Controller) rev.Result

func InterceptMethod

func InterceptMethod(intc InterceptorMethod, when InterceptTime)

Install an interceptor method that applies to its own Controller.

func (c AppController) example() rev.Result
func (c *AppController) example() rev.Result

func MustReadLines

func MustReadLines(filename string) []string

Reads the lines of the given file. Panics in the case of error.

func NotFound

func NotFound(req *Request, resp *Response, msg string)

This function is useful if there is no relevant Controller available. It writes the 404 response immediately.

func ParseKeyValueCookie

func ParseKeyValueCookie(val string, cb func(key, val string))

Takes the raw (escaped) cookie value and parses out key values.

func ReadLines

func ReadLines(filename string) ([]string, error)

Reads the lines of the given file. Panics in the case of error.

func RegisterController

func RegisterController(c interface{}, methods []*MethodType)

Register a Controller and its Methods with Revel.

func RegisterPlugin

func RegisterPlugin(p Plugin)

func RenderError

func RenderError(req *Request, resp *Response, err error)

func ResolveContentType

func ResolveContentType(req *http.Request) string

Get the content type. e.g. From "multipart/form-data; boundary=--" to "multipart/form-data" If none is specified, returns "text/html" by default.

func ResolveFormat

func ResolveFormat(req *http.Request) string

func ReverseUrl

func ReverseUrl(args ...interface{}) string

Return a url capable of invoking a given controller method: "Application.ShowApp 123" => "/app/123"

func Run

func Run(address string, port int)

Run the server. This is called from the generated main file.

func Sign

func Sign(message string) string

Sign a given string with the app-configured secret key. Return the signature in base64 (URLEncoding).

Types

type ActionDefinition

type ActionDefinition struct {
	Host, Method, Url, Action string
	Star                      bool
	Args                      map[string]string
}

func (*ActionDefinition) String

func (a *ActionDefinition) String() string

type BinaryResult

type BinaryResult struct {
	Reader   io.Reader
	Name     string
	Length   int64
	Delivery ContentDisposition
}

func (*BinaryResult) Apply

func (r *BinaryResult) Apply(req *Request, resp *Response)

type Binder

type Binder func(params *Params, name string, typ reflect.Type) reflect.Value

A Binder translates between string parameters and Go data structures.

Here is an example.

Request:

url?id=123&ol[0]=1&ol[1]=2&ul[]=str&ul[]=array&user.Name=rob

Action:

Example.Action(id int, ol []int, ul []string, user User)

Calls:

Binder(params, "id", int): 123
Binder(params, "ol", []int): {1, 2}
Binder(params, "ul", []string): {"str", "array"}
Binder(params, "user", User): User{Name:"rob"}

Note that only exported struct fields may be bound.

func ValueBinder

func ValueBinder(f func(value string, typ reflect.Type) reflect.Value) Binder

An adapter for easily making one-key-value binders.

type Check

type Check interface {
	IsSatisfied(interface{}) bool
	DefaultMessage() string
}

type ContentDisposition

type ContentDisposition string
var (
	Attachment ContentDisposition = "attachment"
	Inline     ContentDisposition = "inline"
)

type Controller

type Controller struct {
	Name       string
	Type       *ControllerType
	MethodType *MethodType

	Request  *Request
	Response *Response

	Flash      Flash                  // User cookie, cleared after each request.
	Session    Session                // Session, stored in cookie, signed.
	Params     *Params                // Parameters from URL and form (including multipart).
	Args       map[string]interface{} // Per-request scratch space.
	RenderArgs map[string]interface{} // Args passed to the template.
	Validation *Validation            // Data validation helpers
	Txn        *sql.Tx                // Nil by default, but may be used by the app / plugins
}

func NewAppController

func NewAppController(req *Request, resp *Response, controllerName, methodName string) (*Controller, reflect.Value)

func NewController

func NewController(req *Request, resp *Response, ct *ControllerType) *Controller

func (*Controller) FlashParams

func (c *Controller) FlashParams()

func (*Controller) Invoke

func (c *Controller) Invoke(appControllerPtr reflect.Value, method reflect.Value, methodArgs []reflect.Value)

Invoke the given method, save headers/cookies to the response, and apply the result. (e.g. render a template to the response)

func (*Controller) NotFound

func (c *Controller) NotFound(msg string) Result

func (*Controller) Redirect

func (c *Controller) Redirect(val interface{}, args ...interface{}) Result

Redirect to an action or to a URL.

c.Redirect(Controller.Action)
c.Redirect("/controller/action")
c.Redirect("/controller/%d/action", id)

func (*Controller) Render

func (c *Controller) Render(extraRenderArgs ...interface{}) Result

Render a template corresponding to the calling Controller method. Arguments will be added to c.RenderArgs prior to rendering the template. They are keyed on their local identifier.

For example:

func (c Users) ShowUser(id int) rev.Result {
	 user := loadUser(id)
	 return c.Render(user)
}

This action will render views/Users/ShowUser.html, passing in an extra key-value "user": (User).

func (*Controller) RenderError

func (c *Controller) RenderError(err error) Result

func (*Controller) RenderFile

func (c *Controller) RenderFile(file *os.File, delivery ContentDisposition) Result

Return a file, either displayed inline or downloaded as an attachment. The name and size are taken from the file info.

func (*Controller) RenderJson

func (c *Controller) RenderJson(o interface{}) Result

Uses encoding/json.Marshal to return JSON to the client.

func (*Controller) RenderTemplate

func (c *Controller) RenderTemplate(templatePath string) Result

A less magical way to render a template. Renders the given template, using the current RenderArgs.

func (*Controller) RenderText

func (c *Controller) RenderText(text string, objs ...interface{}) Result

Render plaintext in response, printf style.

func (*Controller) RenderXml

func (c *Controller) RenderXml(o interface{}) Result

Uses encoding/xml.Marshal to return XML to the client.

func (*Controller) SetCookie

func (c *Controller) SetCookie(cookie *http.Cookie)

func (*Controller) Todo

func (c *Controller) Todo() Result

Render a "todo" indicating that the action isn't done yet.

type ControllerType

type ControllerType struct {
	Type    reflect.Type
	Methods []*MethodType
}

func LookupControllerType

func LookupControllerType(name string) *ControllerType

func (*ControllerType) Method

func (ct *ControllerType) Method(name string) *MethodType

Searches for a given exported method (case insensitive)

type DiscerningListener

type DiscerningListener interface {
	Listener
	WatchDir(info os.FileInfo) bool
	WatchFile(basename string) bool
}

DiscerningListener allows the receiver to selectively watch files.

type EmptyPlugin

type EmptyPlugin struct{}

It provides default (empty) implementations for all the required methods.

func (EmptyPlugin) AfterRequest

func (p EmptyPlugin) AfterRequest(c *Controller)

func (EmptyPlugin) BeforeRequest

func (p EmptyPlugin) BeforeRequest(c *Controller)

func (EmptyPlugin) OnAppStart

func (p EmptyPlugin) OnAppStart()

func (EmptyPlugin) OnException

func (p EmptyPlugin) OnException(c *Controller, err interface{})

type Error

type Error struct {
	SourceType               string   // The type of source that failed to build.
	Title, Path, Description string   // Description of the error, as presented to the user.
	Line, Column             int      // Where the error was encountered.
	SourceLines              []string // The entire source file, split into lines.
	MetaError                string   // Error that occurred producing the error page.
}

An error description, used as an argument to the error template.

func (*Error) ContextSource

func (e *Error) ContextSource() []sourceLine

Returns a snippet of the source around where the error occurred.

func (*Error) Error

func (e *Error) Error() string

Construct a plaintext version of the error, taking account that fields are optionally set. Returns e.g. Compilation Error (in views/header.html:51): expected right delim in end; got "}"

type ErrorResult

type ErrorResult struct {
	RenderArgs map[string]interface{}
	// contains filtered or unexported fields
}

This result handles all kinds of error codes (500, 404, ..). It renders the relevant error page (errors/CODE.format, e.g. errors/500.json). If RunMode is "dev", this results in a friendly error page.

func (ErrorResult) Apply

func (r ErrorResult) Apply(req *Request, resp *Response)

type ExecutableTemplate

type ExecutableTemplate interface {
	Execute(io.Writer, interface{}) error
}

Add some more methods to the default Template.

type Field

type Field struct {
	Name, Value string
	Error       *ValidationError
}

func (*Field) Checked

func (f *Field) Checked(val string) string

Return "checked" if this field.Value matches the provided value

func (*Field) ErrorClass

func (f *Field) ErrorClass() string

type Flash

type Flash struct {
	Data, Out map[string]string
}

Flash represents a cookie that gets overwritten on each request. It allows data to be stored across one page at a time. This is commonly used to implement success or error messages. e.g. the Post/Redirect/Get pattern: http://en.wikipedia.org/wiki/Post/Redirect/Get

func (Flash) Error

func (f Flash) Error(msg string, args ...interface{})

func (Flash) Success

func (f Flash) Success(msg string, args ...interface{})

type GoTemplate

type GoTemplate struct {
	*template.Template
	// contains filtered or unexported fields
}

Adapter for Go Templates.

func (GoTemplate) Content

func (gotmpl GoTemplate) Content() []string

func (GoTemplate) Render

func (gotmpl GoTemplate) Render(wr io.Writer, arg interface{}) error

return a 'rev.Template' from Go's template.

type InterceptTarget

type InterceptTarget int
const (
	ALL_CONTROLLERS InterceptTarget = iota
)

type InterceptTime

type InterceptTime int
const (
	BEFORE InterceptTime = iota
	AFTER
)

type Interception

type Interception struct {
	When InterceptTime
	// contains filtered or unexported fields
}

func (Interception) Invoke

func (i Interception) Invoke(val reflect.Value) reflect.Value

Perform the given interception. val is a pointer to the App Controller.

type InterceptorFunc

type InterceptorFunc func(*Controller) Result

An "interceptor" is a function that is invoked by the framework at a designated time (BEFORE or AFTER) an action invcation.

Since an interceptor may be used across many user Controllers, it is a function that takes the base Controller, rather than a method on a user controller.

An interceptor may optionally return a Result (instead of nil). Depending on when the interceptor was invoked, the response is different: 1. BEFORE: No further interceptors are invoked, and neither is the action. 2. AFTER: Further interceptors are still run. In all cases, any returned Result will take the place of any existing Result. But in the BEFORE case, that returned Result is guaranteed to be final, while in the AFTER case it is possible that a further interceptor could emit its own Result.

Interceptors are called in the order that they are added.

***

Two types of interceptors are provided: Funcs and Methods

Func Interceptors may apply to any / all Controllers.

func example(*rev.Controller) rev.Result

Method Interceptors are provided so that properties can be set on application controllers.

func (c AppController) example() rev.Result
func (c *AppController) example() rev.Result

type InterceptorMethod

type InterceptorMethod interface{}

type Listener

type Listener interface {
	// Refresh is invoked by the watcher on relevant filesystem events.
	// If the listener returns an error, it is served to the user on the current request.
	Refresh() *Error
}

Listener is an interface for receivers of filesystem events.

type Match

type Match struct {
	Regexp *regexp.Regexp
}

Requires a string to match a given regex.

func (Match) DefaultMessage

func (m Match) DefaultMessage() string

func (Match) IsSatisfied

func (m Match) IsSatisfied(obj interface{}) bool

type Max

type Max struct {
	Max int
}

func (Max) DefaultMessage

func (m Max) DefaultMessage() string

func (Max) IsSatisfied

func (m Max) IsSatisfied(obj interface{}) bool

type MaxSize

type MaxSize struct {
	Max int
}

Requires an array or string to be at most a given length.

func (MaxSize) DefaultMessage

func (m MaxSize) DefaultMessage() string

func (MaxSize) IsSatisfied

func (m MaxSize) IsSatisfied(obj interface{}) bool

type MergedConfig

type MergedConfig struct {
	*config.Config
	// contains filtered or unexported fields
}

This handles the parsing of application.conf It has a "preferred" section that is checked first for option queries. If the preferred section does not have the option, the DEFAULT section is checked fallback.

func LoadConfig

func LoadConfig(fname string) (*MergedConfig, error)

func (*MergedConfig) Int

func (c *MergedConfig) Int(option string) (int, error)

func (*MergedConfig) SetSection

func (c *MergedConfig) SetSection(section string)

func (*MergedConfig) String

func (c *MergedConfig) String(option string) (string, error)

type MethodArg

type MethodArg struct {
	Name string
	Type reflect.Type
}

type MethodType

type MethodType struct {
	Name           string
	Args           []*MethodArg
	RenderArgNames map[int][]string
	// contains filtered or unexported fields
}

type Min

type Min struct {
	Min int
}

func (Min) DefaultMessage

func (m Min) DefaultMessage() string

func (Min) IsSatisfied

func (m Min) IsSatisfied(obj interface{}) bool

type MinSize

type MinSize struct {
	Min int
}

Requires an array or string to be at least a given length.

func (MinSize) DefaultMessage

func (m MinSize) DefaultMessage() string

func (MinSize) IsSatisfied

func (m MinSize) IsSatisfied(obj interface{}) bool

type Params

type Params struct {
	url.Values
	Files map[string][]*multipart.FileHeader
	// contains filtered or unexported fields
}

These provide a unified view of the request params. Includes: - URL query string - Form values - File uploads

func ParseParams

func ParseParams(req *Request) *Params

func (*Params) Bind

func (p *Params) Bind(name string, typ reflect.Type) reflect.Value

type PlaintextErrorResult

type PlaintextErrorResult struct {
	// contains filtered or unexported fields
}

func (PlaintextErrorResult) Apply

func (r PlaintextErrorResult) Apply(req *Request, resp *Response)

This method is used when the template loader or error template is not available.

type Plugin

type Plugin interface {
	OnAppStart()
	BeforeRequest(c *Controller)
	AfterRequest(c *Controller)
	OnException(c *Controller, err interface{})
}

An plugin that allows the user to inject behavior at various points in the request cycle.

type PluginCollection

type PluginCollection []Plugin

func (PluginCollection) AfterRequest

func (plugins PluginCollection) AfterRequest(c *Controller)

func (PluginCollection) BeforeRequest

func (plugins PluginCollection) BeforeRequest(c *Controller)

func (PluginCollection) OnAppStart

func (plugins PluginCollection) OnAppStart()

func (PluginCollection) OnException

func (plugins PluginCollection) OnException(c *Controller, err interface{})

type RedirectToActionResult

type RedirectToActionResult struct {
	// contains filtered or unexported fields
}

func (*RedirectToActionResult) Apply

func (r *RedirectToActionResult) Apply(req *Request, resp *Response)

type RedirectToUrlResult

type RedirectToUrlResult struct {
	// contains filtered or unexported fields
}

func (*RedirectToUrlResult) Apply

func (r *RedirectToUrlResult) Apply(req *Request, resp *Response)

type RenderJsonResult

type RenderJsonResult struct {
	// contains filtered or unexported fields
}

func (RenderJsonResult) Apply

func (r RenderJsonResult) Apply(req *Request, resp *Response)

type RenderTemplateResult

type RenderTemplateResult struct {
	Template   Template
	RenderArgs map[string]interface{}
}

Action methods return this result to request a template be rendered.

func (*RenderTemplateResult) Apply

func (r *RenderTemplateResult) Apply(req *Request, resp *Response)

type RenderTextResult

type RenderTextResult struct {
	// contains filtered or unexported fields
}

func (RenderTextResult) Apply

func (r RenderTextResult) Apply(req *Request, resp *Response)

type RenderXmlResult

type RenderXmlResult struct {
	// contains filtered or unexported fields
}

func (RenderXmlResult) Apply

func (r RenderXmlResult) Apply(req *Request, resp *Response)

type Request

type Request struct {
	*http.Request
	ContentType string
	Format      string // "html", "xml", "json", or "text"
}

func NewRequest

func NewRequest(r *http.Request) *Request

type Required

type Required struct{}

func (Required) DefaultMessage

func (r Required) DefaultMessage() string

func (Required) IsSatisfied

func (r Required) IsSatisfied(obj interface{}) bool

type Response

type Response struct {
	Status      int
	ContentType string

	Out http.ResponseWriter
}

func NewResponse

func NewResponse(w http.ResponseWriter) *Response

func (*Response) WriteHeader

func (resp *Response) WriteHeader(defaultStatusCode int, defaultContentType string)

Write the header (for now, just the status code). The status may be set directly by the application (c.Response.Status = 501). if it isn't, then fall back to the provided status code.

type Result

type Result interface {
	Apply(req *Request, resp *Response)
}

type Route

type Route struct {
	Method string // e.g. GET
	Path   string // e.g. /app/{id}
	Action string // e.g. Application.ShowApp
	// contains filtered or unexported fields
}

func NewRoute

func NewRoute(method, path, action string) (r *Route)

Prepares the route to be used in matching.

func (*Route) Match

func (r *Route) Match(method string, reqPath string) *RouteMatch

Return nil if no match.

type RouteMatch

type RouteMatch struct {
	Action         string            // e.g. Application.ShowApp
	ControllerName string            // e.g. Application
	MethodName     string            // e.g. ShowApp
	Params         map[string]string // e.g. {id: 123}
	StaticFilename string
}

type Router

type Router struct {
	Routes []*Route
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(routesPath string) *Router

func (*Router) Refresh

func (router *Router) Refresh() *Error

Refresh re-reads the routes file and re-calculates the routing table. Returns an error if a specified action could not be found.

func (*Router) Reverse

func (router *Router) Reverse(action string, argValues map[string]string) *ActionDefinition

func (*Router) Route

func (router *Router) Route(req *http.Request) *RouteMatch

type Session

type Session map[string]string

A signed cookie (and thus limited to 4kb in size). Restriction: Keys may not have a colon in them.

type Template

type Template interface {
	Name() string
	Content() []string
	Render(wr io.Writer, arg interface{}) error
}

type TemplateLoader

type TemplateLoader struct {
	// contains filtered or unexported fields
}

This object handles loading and parsing of templates. Everything below the application's views directory is treated as a template.

func NewTemplateLoader

func NewTemplateLoader(paths ...string) *TemplateLoader

func (*TemplateLoader) Refresh

func (loader *TemplateLoader) Refresh() *Error

This scans the views directory and parses all templates as Go Templates. If a template fails to parse, the error is set on the loader. (It's awkward to refresh a single Go Template)

func (*TemplateLoader) Template

func (loader *TemplateLoader) Template(name string) (Template, error)

Return the Template with the given name. The name is the template's path relative to a template loader root.

An Error is returned if there was any problem with any of the templates. (In this case, if a template is returned, it may still be usable.)

func (*TemplateLoader) WatchDir

func (loader *TemplateLoader) WatchDir(info os.FileInfo) bool

func (*TemplateLoader) WatchFile

func (loader *TemplateLoader) WatchFile(basename string) bool

type Validation

type Validation struct {
	Errors []*ValidationError
	// contains filtered or unexported fields
}

A Validation context manages data validation and error messages.

func (*Validation) Check

func (v *Validation) Check(obj interface{}, checks ...Check) *ValidationResult

Apply a group of Checks to a field, in order, and return the ValidationResult from the first Check that fails, or the last one that succeeds.

func (*Validation) Clear

func (v *Validation) Clear()

func (*Validation) ErrorMap

func (v *Validation) ErrorMap() map[string]*ValidationError

Return the errors mapped by key. If there are multiple validation errors associated with a single key, the first one "wins". (Typically the first validation will be the more basic).

func (*Validation) HasErrors

func (v *Validation) HasErrors() bool

func (*Validation) Keep

func (v *Validation) Keep()

func (*Validation) Match

func (v *Validation) Match(str string, regex *regexp.Regexp) *ValidationResult

func (*Validation) Max

func (v *Validation) Max(n int, max int) *ValidationResult

func (*Validation) MaxSize

func (v *Validation) MaxSize(obj interface{}, max int) *ValidationResult

func (*Validation) Min

func (v *Validation) Min(n int, min int) *ValidationResult

func (*Validation) MinSize

func (v *Validation) MinSize(obj interface{}, min int) *ValidationResult

func (*Validation) Required

func (v *Validation) Required(obj interface{}) *ValidationResult

Test that the argument is non-nil and non-empty (if string or list)

type ValidationError

type ValidationError struct {
	Message, Key string
}

func (*ValidationError) String

func (e *ValidationError) String() string

Returns the Message.

type ValidationResult

type ValidationResult struct {
	Error *ValidationError
	Ok    bool
}

A ValidationResult is returned from every validation method. It provides an indication of success, and a pointer to the Error (if any).

func (*ValidationResult) Key

func (*ValidationResult) Message

func (r *ValidationResult) Message(message string) *ValidationResult

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher allows listeners to register to be notified of changes under a given directory.

func NewWatcher

func NewWatcher() *Watcher

func (*Watcher) Listen

func (w *Watcher) Listen(listener Listener, roots ...string)

Listen registers for events within the given root directories (recursively).

func (*Watcher) Notify

func (w *Watcher) Notify() *Error

Notify causes the watcher to forward any change events to listeners. It returns the first (if any) error returned.

Directories

Path Synopsis
The command line tool for running Revel apps.
The command line tool for running Revel apps.
samples
skeleton

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL