model

package
v1.0.0-...-5f558ac Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

This package will be shared between Revel and Revel CLI eventually

Index

Constants

This section is empty.

Variables

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

RevelImportPath Revel framework import path

View Source
var RevelModulesImportPath = "github.com/revel/modules"

Functions

func AddInitEventHandler

func AddInitEventHandler(handler EventHandler)

Add event handler to listen for all system events

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
)

The constants

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
	FrameworkVersion *Version                   // The framework version
	CommandVersion   *Version                   // The command version
	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 (relative to a GOPATH)
	GoPath           string                     // The GoPath
	GoCmd            string                     // The full path to the go executable
	SrcRoot          string                     // The source root
	AppPath          string                     // The application path (absolute)
	AppName          string                     // The application name
	Vendored         bool                       // True if the application is vendored
	PackageResolver  func(pkgName string) error //  a packge resolver for the config
	BuildFlags       []string                   `` /* 186-byte string literal not displayed */
	// The new command
	New struct {
		ImportPath   string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
		SkeletonPath 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 `` /* 129-byte string literal not displayed */
		ImportPath string `short:"a" long:"application-path" description:"Path to application folder"  required:"false"`
		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 application folder"  required:"false"`
		Mode       string `short:"m" long:"run-mode" description:"The mode to run the application in"`
		Port       int    `short:"p" long:"port" default:"-1" description:"The port to listen" `
		NoProxy    bool   `` /* 141-byte string literal not displayed */
	} `command:"run"`
	// The package command
	Package struct {
		TargetPath string `short:"t" long:"target-path" description:"Full path and filename of target package to deploy" required:"false"`
		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 application folder"  required:"false"`
		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 application folder"  required:"false"`
	} `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 application folder" required:"false"`
		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 application folder" required:"false"`
		Update     bool   `short:"u" long:"Update the framework and modules" required:"false"`
	} `command:"version"`
}

The Command config for the line input

func (*CommandConfig) InitGoPaths

func (c *CommandConfig) InitGoPaths()

lookup and set Go related variables

func (*CommandConfig) InitPackageResolver

func (c *CommandConfig) InitPackageResolver()

Used to initialize the package resolver

func (*CommandConfig) SetVersions

func (c *CommandConfig) SetVersions() (err error)

Sets the versions on the command config

func (*CommandConfig) UpdateImportPath

func (c *CommandConfig) UpdateImportPath() error

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 Event

type Event int

The event type

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 Event = 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 before module loads, events thrown to handlers added to AddInitEventHandler
	REVEL_BEFORE_MODULE_LOADED
	// Event type after module loads, events thrown to handlers added to AddInitEventHandler
	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

	// Fired when a panic is caught during the startup process
	REVEL_FAILURE
)

type EventHandler

type EventHandler func(typeOf Event, value interface{}) (responseOf EventResponse)

The handler signature

type EventResponse

type EventResponse int

The event response

func RaiseEvent

func RaiseEvent(key Event, value interface{}) (response EventResponse)

Fires system events from revel

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 Event, value interface{}) (response EventResponse)
	PackageResolver(pkgName string) error
}

func NewWrappedRevelCallback

func NewWrappedRevelCallback(fe func(key Event, value interface{}) (response EventResponse), ie func(pkgName string) error) RevelCallback

Simple Wrapped RevelCallback

type RevelContainer

type RevelContainer struct {
	BuildPaths struct {
		Revel string
	}
	Paths struct {
		Import   string
		Source   string
		Base     string
		App      string
		Views    string
		Code     []string
		Template []string
		Config   []string
	}
	PackageInfo struct {
		Config   config.Context
		Packaged bool
		DevMode  bool
		Vendor   bool
	}
	Application struct {
		Name string
		Root string
	}

	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, err error)

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() (err error)

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

type Version

type Version struct {
	Prefix       string
	Major        int
	Minor        int
	Maintenance  int
	Suffix       string
	BuildDate    string
	MinGoVersion string
}

func ParseVersion

func ParseVersion(version string) (v *Version, err error)

Parse the version and return it as a Version object

func (*Version) CompatibleFramework

func (v *Version) CompatibleFramework(c *CommandConfig) error

Returns true if this major revision is compatible

func (*Version) MajorNewer

func (v *Version) MajorNewer(o *Version) bool

Returns true if this major revision is newer then the passed in

func (*Version) MinorNewer

func (v *Version) MinorNewer(o *Version) bool

Returns true if this major or major and minor revision is newer then the value passed in

func (*Version) Newer

func (v *Version) Newer(o *Version) bool

Returns true if the version is newer then the current on

func (*Version) ParseVersion

func (v *Version) ParseVersion(version string) (err error)

Parse the version and return it as a Version object

func (*Version) String

func (v *Version) String() string

Convert the version build date and go version to a string

func (*Version) VersionString

func (v *Version) VersionString() string

Convert the version to a string

type WrappedRevelCallback

type WrappedRevelCallback struct {
	FireEventFunction func(key Event, value interface{}) (response EventResponse)
	ImportFunction    func(pkgName string) error
}

func (*WrappedRevelCallback) FireEvent

func (w *WrappedRevelCallback) FireEvent(key Event, value interface{}) (response EventResponse)

Function to implement the FireEvent

func (*WrappedRevelCallback) PackageResolver

func (w *WrappedRevelCallback) PackageResolver(pkgName string) error

Jump to

Keyboard shortcuts

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