model

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

This package will be shared between Revel and Revel CLI eventually

Index

Constants

View Source
const (
	// Event type when templates are going to be refreshed (receivers are registered template engines added to the template.engine conf option)
	TEMPLATE_REFRESH_REQUESTED = iota
	// Event type when templates are refreshed (receivers are registered template engines added to the template.engine conf option)
	TEMPLATE_REFRESH_COMPLETED

	// Event type before all module loads, events thrown to handlers added to AddInitEventHandler
	REVEL_BEFORE_MODULES_LOADED
	// Event type called when a new module is found
	REVEL_BEFORE_MODULE_LOADED
	// Event type called when after a new module is found
	REVEL_AFTER_MODULE_LOADED
	// Event type after all module loads, events thrown to handlers added to AddInitEventHandler
	REVEL_AFTER_MODULES_LOADED

	// Event type before server engine is initialized, receivers are active server engine and handlers added to AddInitEventHandler
	ENGINE_BEFORE_INITIALIZED
	// Event type before server engine is started, receivers are active server engine and handlers added to AddInitEventHandler
	ENGINE_STARTED
	// Event type after server engine is stopped, receivers are active server engine and handlers added to AddInitEventHandler
	ENGINE_SHUTDOWN

	// Called before routes are refreshed
	ROUTE_REFRESH_REQUESTED
	// Called after routes have been refreshed
	ROUTE_REFRESH_COMPLETED
)

Variables

View Source
var DoNothingRevelCallback = RevelCallback(&doNothingRevelCallback{})

Simple callback to pass to the RevelCallback that does nothing

View Source
var RevelImportPath = "github.com/revel/revel"

RevelImportPath Revel framework import path

Functions

func FirstNonEmpty

func FirstNonEmpty(strs ...string) string

Returns the first non empty string from a list of arguements

func IsBuiltinType

func IsBuiltinType(name string) bool

IsBuiltinType checks the given type is built-in types of Go

Types

type COMMAND

type COMMAND int

The Revel command type

const (
	NEW COMMAND = iota + 1
	RUN
	BUILD
	PACKAGE
	CLEAN
	TEST
	VERSION
)

type CommandConfig

type CommandConfig struct {
	Index        COMMAND  // The index
	Verbose      bool     `short:"v" long:"debug" description:"If set the logger is set to verbose"`              // True if debug is active
	HistoricMode bool     `long:"historic-run-mode" description:"If set the runmode is passed a string not json"` // True if debug is active
	ImportPath   string   // The import path (converted from various commands)
	GoPath       string   // The GoPath
	GoCmd        string   // The full path to the go executable
	SrcRoot      string   // The source root
	AppPath      string   // The application path
	AppName      string   // The applicaiton name
	BasePath     string   // The base path
	SkeletonPath string   // The skeleton path
	BuildFlags   []string `` /* 186-byte string literal not displayed */
	// The new command
	New struct {
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder" required:"true"`
		Skeleton   string `short:"s" long:"skeleton" description:"Path to skeleton folder (Must exist on GO PATH)" required:"false"`
		Vendored   bool   `` /* 167-byte string literal not displayed */
		Run        bool   `short:"r" long:"run" description:"True if you want to run the application right away"`
	} `command:"new"`
	// The build command
	Build struct {
		TargetPath string `` /* 128-byte string literal not displayed */
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder"  required:"true"`
		Mode       string `short:"m" long:"run-mode" description:"The mode to run the application in"`
		CopySource bool   `short:"s" long:"include-source" description:"Copy the source code as well"`
	} `command:"build"`
	// The run command
	Run struct {
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder"  required:"true"`
		Mode       string `short:"m" long:"run-mode" description:"The mode to run the application in"`
		Port       string `short:"p" long:"port" description:"The port to listen"`
		NoProxy    bool   `` /* 141-byte string literal not displayed */
	} `command:"run"`
	// The package command
	Package struct {
		Mode       string `short:"m" long:"run-mode" description:"The mode to run the application in"`
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder"  required:"true"`
		CopySource bool   `short:"s" long:"include-source" description:"Copy the source code as well"`
	} `command:"package"`
	// The clean command
	Clean struct {
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder"  required:"true"`
	} `command:"clean"`
	// The test command
	Test struct {
		Mode       string `short:"m" long:"run-mode" description:"The mode to run the application in"`
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder" required:"true"`
		Function   string `short:"f" long:"suite-function" description:"The suite.function"`
	} `command:"test"`
	// The version command
	Version struct {
		ImportPath string `short:"a" long:"application-path" description:"Path to applicaiton folder" required:"false"`
	} `command:"version"`
}

The Command config for the line input

func (*CommandConfig) UpdateImportPath

func (c *CommandConfig) UpdateImportPath() bool

Updates the import path depending on the command

type EmbeddedTypeName

type EmbeddedTypeName struct {
	ImportPath, StructName string
}

The embedded type name takes the import path and structure name

func (*EmbeddedTypeName) String

func (s *EmbeddedTypeName) String() string

Convert the type to a properly formatted import line

type MethodArg

type MethodArg struct {
	Name       string   // Name of the argument.
	TypeExpr   TypeExpr // The name of the type, e.g. "int", "*pkg.UserType"
	ImportPath string   // If the arg is of an imported type, this is the import path.
}

MethodArg holds the information of one argument

type MethodCall

type MethodCall struct {
	Path  string // e.g. "myapp/app/controllers.(*Application).Action"
	Line  int
	Names []string
}

methodCall describes a call to c.Render(..) It documents the argument names used, in order to propagate them to RenderArgs.

type MethodSpec

type MethodSpec struct {
	Name        string        // Name of the method, e.g. "Index"
	Args        []*MethodArg  // Argument descriptors
	RenderCalls []*MethodCall // Descriptions of Render() invocations from this Method.
}

MethodSpec holds the information of one Method

type RevelCallback

type RevelCallback interface {
	FireEvent(key int, value interface{}) (response int)
}

type RevelContainer

type RevelContainer struct {
	ImportPath    string            // The import path
	SourcePath    string            // The full source path
	RunMode       string            // The current run mode
	RevelPath     string            // The path to the Revel source code
	BasePath      string            // The base path to the application
	AppPath       string            // The application path (BasePath + "/app"
	ViewsPath     string            // The application views path
	CodePaths     []string          // All the code paths
	TemplatePaths []string          // All the template paths
	ConfPaths     []string          // All the configuration paths
	Config        *config.Context   // The global config object
	Packaged      bool              // True if packaged
	DevMode       bool              // True if running in dev mode
	HTTPPort      int               // The http port
	HTTPAddr      string            // The http address
	HTTPSsl       bool              // True if running https
	HTTPSslCert   string            // The SSL certificate
	HTTPSslKey    string            // The SSL key
	AppName       string            // The application name
	AppRoot       string            // The application root from the config `app.root`
	CookiePrefix  string            // The cookie prefix
	CookieDomain  string            // The cookie domain
	CookieSecure  bool              // True if cookie is secure
	SecretStr     string            // The secret string
	MimeConfig    *config.Context   // The mime configuration
	ModulePathMap map[string]string // The module path map
}

The container object for describing all Revels variables

func NewRevelPaths

func NewRevelPaths(mode, importPath, srcPath string, callback RevelCallback) (rp *RevelContainer)

This function returns a container object describing the revel application eventually this type of function will replace the global variables.

func (*RevelContainer) LoadMimeConfig

func (rp *RevelContainer) LoadMimeConfig()

LoadMimeConfig load mime-types.conf on init.

func (*RevelContainer) ResolveImportPath

func (rp *RevelContainer) ResolveImportPath(importPath string) (string, error)

ResolveImportPath returns the filesystem path for the given import path. Returns an error if the import path could not be found.

type SourceInfo

type SourceInfo struct {
	// StructSpecs lists type info for all structs found under the code paths.
	// They may be queried to determine which ones (transitively) embed certain types.
	StructSpecs []*TypeInfo
	// ValidationKeys provides a two-level lookup.  The keys are:
	// 1. The fully-qualified function name,
	//    e.g. "github.com/revel/examples/chat/app/controllers.(*Application).Action"
	// 2. Within that func's file, the line number of the (overall) expression statement.
	//    e.g. the line returned from runtime.Caller()
	// The result of the lookup the name of variable being validated.
	ValidationKeys map[string]map[int]string
	// A list of import paths.
	// Revel notices files with an init() function and imports that package.
	InitImportPaths []string
	// contains filtered or unexported fields
}

func (*SourceInfo) ControllerSpecs

func (s *SourceInfo) ControllerSpecs() []*TypeInfo

ControllerSpecs returns the all the controllers that embeds `revel.Controller`

func (*SourceInfo) TestSuites

func (s *SourceInfo) TestSuites() []*TypeInfo

TestSuites returns the all the Application tests that embeds `testing.TestSuite`

func (*SourceInfo) TypesThatEmbed

func (s *SourceInfo) TypesThatEmbed(targetType, packageFilter string) (filtered []*TypeInfo)

TypesThatEmbed returns all types that (directly or indirectly) embed the target type, which must be a fully qualified type name, e.g. "github.com/revel/revel.Controller"

type TypeExpr

type TypeExpr struct {
	Expr    string // The unqualified type expression, e.g. "[]*MyType"
	PkgName string // The default package idenifier

	Valid bool
	// contains filtered or unexported fields
}

func NewTypeExprFromAst

func NewTypeExprFromAst(pkgName string, expr ast.Expr) TypeExpr

NewTypeExpr returns the syntactic expression for referencing this type in Go.

func NewTypeExprFromData

func NewTypeExprFromData(expr, pkgName string, pkgIndex int, valid bool) TypeExpr

Returns a new type from the data

func (TypeExpr) TypeName

func (e TypeExpr) TypeName(pkgOverride string) string

TypeName returns the fully-qualified type name for this expression. The caller may optionally specify a package name to override the default.

type TypeInfo

type TypeInfo struct {
	StructName    string              // e.g. "Application"
	ImportPath    string              // e.g. "github.com/revel/examples/chat/app/controllers"
	PackageName   string              // e.g. "controllers"
	MethodSpecs   []*MethodSpec       // Method specifications, the action functions
	EmbeddedTypes []*EmbeddedTypeName // Used internally to identify controllers that indirectly embed *revel.Controller.
}

TypeInfo summarizes information about a struct type in the app source code.

func (*TypeInfo) String

func (s *TypeInfo) String() string

Return the type information as a properly formatted import string

Jump to

Keyboard shortcuts

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