Documentation ¶
Overview ¶
Package harness for a Revel Framework.
It has a following responsibilities:
- Parse the user program, generating a main.go file that registers controller classes and starts the user's server.
- Build and run the user program. Show compile errors.
- Monitor the user source and re-build / restart the program when necessary.
Source files are generated in the app/tmp directory.
Index ¶
Constants ¶
const RevelMainTemplate = `` /* 1661-byte string literal not displayed */
RevelMainTemplate template for app/tmp/main.go
const RevelRoutesTemplate = `` /* 557-byte string literal not displayed */
RevelRoutesTemplate template for app/conf/routes
Variables ¶
This section is empty.
Functions ¶
func IsBuiltinType ¶
IsBuiltinType checks the given type is built-in types of Go
Types ¶
type App ¶
type App struct { BinaryPath string // Path to the app executable Port int // Port to pass as a command line argument. // contains filtered or unexported fields }
App contains the configuration for running a Revel app. (Not for the app itself) Its only purpose is constructing the command to execute.
func Build ¶
Build the app: 1. Generate the the main.go file. 2. Run the appropriate "go build" command. Requires that revel.Init has been called previously. Returns the path to the built binary, and an error if there was a problem building it.
type AppCmd ¶
AppCmd manages the running of a Revel app server. It requires revel.Init to have been called previously.
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness reverse proxies requests to the application server. It builds / runs / rebuilds / restarts the server when code is changed.
func NewHarness ¶
func NewHarness() *Harness
NewHarness method returns a reverse proxy that forwards requests to the given port.
func (*Harness) Refresh ¶
Refresh method rebuilds the Revel application and run it on the given port.
func (*Harness) Run ¶
func (h *Harness) Run()
Run the harness, which listens for requests and proxies them to the app server, which it runs and rebuilds as necessary.
func (*Harness) ServeHTTP ¶
func (h *Harness) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles all requests. It checks for changes to app, rebuilds if necessary, and forwards the request.
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 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 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 }
SourceInfo is the top-level struct containing all extracted information about the app source code, used to generate main.go.
func ProcessSource ¶
func ProcessSource(roots []string) (*SourceInfo, *revel.Error)
ProcessSource parses the app controllers directory and returns a list of the controller types found. Otherwise CompileError if the parsing fails.
func (*SourceInfo) ControllerSpecs ¶
func (s *SourceInfo) ControllerSpecs() []*TypeInfo
ControllerSpecs returns the all the contollers 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 }
TypeExpr provides a type name that may be rewritten to use a package name.
func NewTypeExpr ¶
NewTypeExpr returns the syntactic expression for referencing this type in Go.
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 // contains filtered or unexported fields }
TypeInfo summarizes information about a struct type in the app source code.