v0.21.1 Latest Latest

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 29 Imported by: 0



Package harness for a Revel Framework.

It has a following responsibilities:

  1. Parse the user program, generating a main.go file that registers controller classes and starts the user's server.
  2. Build and run the user program. Show compile errors.
  3. Monitor the user source and re-build / restart the program when necessary.

Source files are generated in the app/tmp directory.



View Source
const RevelMainTemplate = `` /* 717-byte string literal not displayed */
View Source
const RevelRoutesTemplate = `` /* 661-byte string literal not displayed */

RevelRoutesTemplate template for app/conf/routes

View Source
const RevelRunTemplate = `` /* 1594-byte string literal not displayed */

RevelMainTemplate template for app/tmp/main.go


This section is empty.


This section is empty.


type App

type App struct {
	BinaryPath string // Path to the app executable
	Port       int    // Port to pass as a command line argument.

	Paths *model.RevelContainer
	// 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

func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err error)

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.

func NewApp

func NewApp(binPath string, paths *model.RevelContainer) *App

NewApp returns app instance with binary path in it

func (*App) Cmd

func (a *App) Cmd(runMode string) AppCmd

Cmd returns a command to run the app server using the current configuration.

func (*App) Kill

func (a *App) Kill()

Kill the last app command returned.

type AppCmd

type AppCmd struct {

AppCmd manages the running of a Revel app server. It requires revel.Init to have been called previously.

func NewAppCmd

func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelContainer) AppCmd

NewAppCmd returns the AppCmd with parameters initialized for running app

func (AppCmd) Kill

func (cmd AppCmd) Kill()

Kill terminates the app server if it's running.

func (AppCmd) Run

func (cmd AppCmd) Run()

Run the app server inline. Never returns.

func (AppCmd) Start

func (cmd AppCmd) Start(c *model.CommandConfig) error

Start the app server, and wait until it is ready to serve requests.

type ByString

type ByString []*model.TypeInfo

func (ByString) Len

func (c ByString) Len() int

func (ByString) Less

func (c ByString) Less(i, j int) bool

func (ByString) Swap

func (c ByString) Swap(i, j int)

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(c *model.CommandConfig, paths *model.RevelContainer, runMode string, noProxy bool) *Harness

NewHarness method returns a reverse proxy that forwards requests to the given port.

func (*Harness) Refresh

func (h *Harness) Refresh() (err *utils.Error)

Refresh method rebuilds the Revel application and run it on the given port. called by the watcher

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.

func (*Harness) WatchDir

func (h *Harness) WatchDir(info os.FileInfo) bool

WatchDir method returns false to file matches with doNotWatch otheriwse true

func (*Harness) WatchFile

func (h *Harness) WatchFile(filename string) bool

WatchFile method returns true given filename HasSuffix of ".go" otheriwse false - implements revel.DiscerningListener

Jump to

Keyboard shortcuts

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