mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-12 11:05:19 +00:00
Compare commits
19 Commits
v0.14.1
...
server-eng
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18e6b92704 | ||
|
|
49041fb83d | ||
|
|
f86def601d | ||
|
|
15875dc9a1 | ||
|
|
16f98f92e0 | ||
|
|
9de11613ce | ||
|
|
e1776bda3c | ||
|
|
32d1f12b51 | ||
|
|
d114a92b3d | ||
|
|
8bf654d8b0 | ||
|
|
79ed869901 | ||
|
|
d68b27ae81 | ||
|
|
ce84b78204 | ||
|
|
19ca52182d | ||
|
|
bf30aab381 | ||
|
|
bd4663b651 | ||
|
|
b81860de5f | ||
|
|
3ba212afb4 | ||
|
|
d2b1730439 |
@@ -88,8 +88,9 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
|
|||||||
revel.ImportPath, appVersion, revel.ImportPath, buildTime)
|
revel.ImportPath, appVersion, revel.ImportPath, buildTime)
|
||||||
|
|
||||||
// TODO remove version check for versionLinkerFlags after Revel becomes Go min version to go1.5
|
// TODO remove version check for versionLinkerFlags after Revel becomes Go min version to go1.5
|
||||||
goVersion, _ := strconv.ParseFloat(runtime.Version()[2:5], 64)
|
goVersion, err := strconv.ParseFloat(runtime.Version()[2:5], 64)
|
||||||
if goVersion < 1.5 {
|
// runtime.Version() may return commit hash, we assume it is above 1.5
|
||||||
|
if goVersion < 1.5 && err == nil {
|
||||||
versionLinkerFlags = fmt.Sprintf("-X %s/app.AppVersion \"%s\" -X %s/app.BuildTime \"%s\"",
|
versionLinkerFlags = fmt.Sprintf("-X %s/app.AppVersion \"%s\" -X %s/app.BuildTime \"%s\"",
|
||||||
revel.ImportPath, appVersion, revel.ImportPath, buildTime)
|
revel.ImportPath, appVersion, revel.ImportPath, buildTime)
|
||||||
}
|
}
|
||||||
@@ -286,7 +287,7 @@ func calcImportAliases(src *SourceInfo) map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addAlias(aliases map[string]string, importPath, pkgName string) {
|
func addAlias(aliases map[string]string, importPath, pkgName string) {
|
||||||
alias, ok := aliases[importPath]
|
alias, ok := aliases[importPath]
|
||||||
if ok {
|
if ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -297,7 +298,7 @@ func addAlias(aliases map[string]string, importPath, pkgName string) {
|
|||||||
func makePackageAlias(aliases map[string]string, pkgName string) string {
|
func makePackageAlias(aliases map[string]string, pkgName string) string {
|
||||||
i := 0
|
i := 0
|
||||||
alias := pkgName
|
alias := pkgName
|
||||||
for containsValue(aliases, alias) {
|
for containsValue(aliases, alias) || alias=="revel" {
|
||||||
alias = fmt.Sprintf("%s%d", pkgName, i)
|
alias = fmt.Sprintf("%s%d", pkgName, i)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ type Harness struct {
|
|||||||
proxy *httputil.ReverseProxy
|
proxy *httputil.ReverseProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderError(w http.ResponseWriter, r *http.Request, err error) {
|
func renderError(iw http.ResponseWriter, ir *http.Request, err error) {
|
||||||
req, resp := revel.NewRequest(r), revel.NewResponse(w)
|
context := revel.NewGOContext(nil)
|
||||||
c := revel.NewController(req, resp)
|
context.Request.SetRequest(ir)
|
||||||
c.RenderError(err).Apply(req, resp)
|
context.Response.SetResponse(iw)
|
||||||
|
c := revel.NewController(context)
|
||||||
|
c.RenderError(err).Apply(c.Request, c.Response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeHTTP handles all requests.
|
// ServeHTTP handles all requests.
|
||||||
|
|||||||
@@ -160,8 +160,20 @@ func ProcessSource(roots []string) (*SourceInfo, *revel.Error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore packages that end with _test
|
||||||
|
for i := range pkgs {
|
||||||
|
if len(i) > 6 {
|
||||||
|
if string(i[len(i)-5:]) == "_test" {
|
||||||
|
delete(pkgs, i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// There should be only one package in this directory.
|
// There should be only one package in this directory.
|
||||||
if len(pkgs) > 1 {
|
if len(pkgs) > 1 {
|
||||||
|
for i := range pkgs {
|
||||||
|
println("Found package ", i)
|
||||||
|
}
|
||||||
log.Println("Most unexpected! Multiple packages in a single directory:", pkgs)
|
log.Println("Most unexpected! Multiple packages in a single directory:", pkgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,12 @@ func parseRunArgs(args []string) *RunArgs {
|
|||||||
// 1. revel run [import-path]
|
// 1. revel run [import-path]
|
||||||
// 2. revel run [port]
|
// 2. revel run [port]
|
||||||
// 3. revel run [run-mode]
|
// 3. revel run [run-mode]
|
||||||
if _, err := build.Import(args[0], "", build.FindOnly); err == nil {
|
_, err := build.Import(args[0], "", build.FindOnly)
|
||||||
|
if err != nil {
|
||||||
|
revel.WARN.Printf("Unable to run using an import path, assuming import path is working directory %s %s", args[0], err.Error())
|
||||||
|
}
|
||||||
|
println("Trying to build with", args[0], err)
|
||||||
|
if err == nil {
|
||||||
// 1st arg is the import path
|
// 1st arg is the import path
|
||||||
inputArgs.ImportPath = args[0]
|
inputArgs.ImportPath = args[0]
|
||||||
} else if port, err := strconv.Atoi(args[0]); err == nil {
|
} else if port, err := strconv.Atoi(args[0]); err == nil {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func init() {
|
|||||||
revel.ActionInvoker, // Invoke the action.
|
revel.ActionInvoker, // Invoke the action.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// register startup functions with OnAppStart
|
// register startup functions with OnAppStart
|
||||||
// revel.DevMode and revel.RunMode only work inside of OnAppStart. See Example Startup Script
|
// revel.DevMode and revel.RunMode only work inside of OnAppStart. See Example Startup Script
|
||||||
// ( order dependent )
|
// ( order dependent )
|
||||||
@@ -43,9 +42,9 @@ func init() {
|
|||||||
// should probably also have a filter for CSRF
|
// should probably also have a filter for CSRF
|
||||||
// not sure if it can go in the same filter or not
|
// not sure if it can go in the same filter or not
|
||||||
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
|
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
|
||||||
c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
|
c.Response.SetHttpHeader("X-Frame-Options", "SAMEORIGIN")
|
||||||
c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
|
c.Response.SetHttpHeader("X-XSS-Protection", "1; mode=block")
|
||||||
c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")
|
c.Response.SetHttpHeader("X-Content-Type-Options", "nosniff")
|
||||||
|
|
||||||
fc[0](c, fc[1:]) // Execute the next filter stage.
|
fc[0](c, fc[1:]) // Execute the next filter stage.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
# More info at http://revel.github.io/manual/appconf.html
|
# More info at http://revel.github.io/manual/appconf.html
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Sets the `AppName` variable which can be used in your code as
|
# Sets `revel.AppName` for use in-app.
|
||||||
|
# Example:
|
||||||
# `if revel.AppName {...}`
|
# `if revel.AppName {...}`
|
||||||
app.name = {{ .AppName }}
|
app.name = {{ .AppName }}
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ app.name = {{ .AppName }}
|
|||||||
# into your application
|
# into your application
|
||||||
app.secret = {{ .Secret }}
|
app.secret = {{ .Secret }}
|
||||||
|
|
||||||
# Revel running behind proxy like nginx, haproxy, etc
|
# Revel running behind proxy like nginx, haproxy, etc.
|
||||||
app.behind.proxy = false
|
app.behind.proxy = false
|
||||||
|
|
||||||
|
|
||||||
@@ -57,10 +58,11 @@ cookie.prefix = REVEL
|
|||||||
# as false.
|
# as false.
|
||||||
# cookie.secure = false
|
# cookie.secure = false
|
||||||
|
|
||||||
# Limit cookie access to a given domain
|
# Limit cookie access to a given domain.
|
||||||
#cookie.domain =
|
#cookie.domain =
|
||||||
|
|
||||||
# Define when your session cookie expires. Possible values:
|
# Define when your session cookie expires.
|
||||||
|
# Values:
|
||||||
# "720h"
|
# "720h"
|
||||||
# A time duration (http://golang.org/pkg/time/#ParseDuration) after which
|
# A time duration (http://golang.org/pkg/time/#ParseDuration) after which
|
||||||
# the cookie expires and the session is invalid.
|
# the cookie expires and the session is invalid.
|
||||||
@@ -82,7 +84,7 @@ format.datetime = 2006-01-02 15:04
|
|||||||
results.chunked = false
|
results.chunked = false
|
||||||
|
|
||||||
|
|
||||||
# Prefixes for each log message line
|
# Prefixes for each log message line.
|
||||||
# User can override these prefix values within any section
|
# User can override these prefix values within any section
|
||||||
# For e.g: [dev], [prod], etc
|
# For e.g: [dev], [prod], etc
|
||||||
log.trace.prefix = "TRACE "
|
log.trace.prefix = "TRACE "
|
||||||
@@ -107,30 +109,57 @@ module.static=github.com/revel/modules/static
|
|||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Section: dev
|
# Section: dev
|
||||||
# This section is evaluated when running Revel in dev mode. Like so:
|
# This section is evaluated when running Revel in dev mode. Like so:
|
||||||
# `revel run path/to/myapp`
|
# `revel run path/to/myapp`
|
||||||
[dev]
|
[dev]
|
||||||
# This sets `DevMode` variable to `true` which can be used in your code as
|
|
||||||
|
# This sets `revel.DevMode` for use in-app.
|
||||||
|
# Example:
|
||||||
# `if revel.DevMode {...}`
|
# `if revel.DevMode {...}`
|
||||||
# or in your templates with
|
# or in your templates with
|
||||||
# `{{.DevMode}}`
|
# `{{.DevMode}}`
|
||||||
|
# Values:
|
||||||
|
# "true"
|
||||||
|
# Sets `DevMode` to `true`.
|
||||||
|
# "false"
|
||||||
|
# Sets `DevMode` to `false`.
|
||||||
mode.dev = true
|
mode.dev = true
|
||||||
|
|
||||||
|
|
||||||
# Pretty print JSON/XML when calling RenderJSON/RenderXML
|
# Pretty print JSON/XML when calling RenderJSON/RenderXML
|
||||||
|
# Values:
|
||||||
|
# "true"
|
||||||
|
# Enables pretty printing.
|
||||||
|
# "false"
|
||||||
|
# Disables pretty printing.
|
||||||
results.pretty = true
|
results.pretty = true
|
||||||
|
|
||||||
|
|
||||||
# Automatically watches your applicaton files and recompiles on-demand
|
# Watch your applicaton files for changes and automatically rebuild
|
||||||
|
# Values:
|
||||||
|
# "true"
|
||||||
|
# Enables auto rebuilding.
|
||||||
|
# "false"
|
||||||
|
# Disables auto rebuilding.
|
||||||
watch = true
|
watch = true
|
||||||
|
|
||||||
|
|
||||||
# If you set watch.mode = "eager", the server starts to recompile
|
# Define when to rebuild new changes.
|
||||||
# your application every time your application's files change.
|
# Values:
|
||||||
watch.mode = "normal"
|
# "normal"
|
||||||
|
# Rebuild when a new request is received and changes have been detected.
|
||||||
|
# "eager"
|
||||||
|
# Rebuild as soon as changes are detected.
|
||||||
|
watch.mode = normal
|
||||||
|
|
||||||
# Watch the entire $GOPATH for code changes. Default is false.
|
# Watch the entire `$GOPATH` for changes.
|
||||||
|
# Values:
|
||||||
|
# "true"
|
||||||
|
# Includes `$GOPATH` in watch path.
|
||||||
|
# "false"
|
||||||
|
# Excludes `$GOPATH` from watch path. Default value.
|
||||||
#watch.gopath = true
|
#watch.gopath = true
|
||||||
|
|
||||||
|
|
||||||
@@ -141,20 +170,34 @@ module.testrunner = github.com/revel/modules/testrunner
|
|||||||
|
|
||||||
|
|
||||||
# Where to log the various Revel logs
|
# Where to log the various Revel logs
|
||||||
|
# Values:
|
||||||
|
# "off"
|
||||||
|
# Disable log output.
|
||||||
|
# "stdout"
|
||||||
|
# Log to OS's standard output.
|
||||||
|
# "stderr"
|
||||||
|
# Log to Os's standard error output. Default value.
|
||||||
|
# "relative/path/to/log"
|
||||||
|
# Log to file.
|
||||||
log.trace.output = off
|
log.trace.output = off
|
||||||
log.info.output = stderr
|
log.info.output = stderr
|
||||||
log.warn.output = stderr
|
log.warn.output = stderr
|
||||||
log.error.output = stderr
|
log.error.output = stderr
|
||||||
|
|
||||||
|
|
||||||
# Revel log flags. Possible flags defined by the Go `log` package,
|
# Revel log flags. Possible flags defined by the Go `log` package. Go log is
|
||||||
# please refer https://golang.org/pkg/log/#pkg-constants
|
# "Bits OR'ed together to control what's printed
|
||||||
# Go log is "Bits or'ed together to control what's printed"
|
# See:
|
||||||
# Examples:
|
# https://golang.org/pkg/log/#pkg-constants
|
||||||
# 0 => just log the message, turn off the flags
|
# Values:
|
||||||
# 3 => log.LstdFlags (log.Ldate|log.Ltime)
|
# "0"
|
||||||
# 19 => log.Ldate|log.Ltime|log.Lshortfile
|
# Just log the message, turn off the flags.
|
||||||
# 23 => log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile
|
# "3"
|
||||||
|
# log.LstdFlags (log.Ldate|log.Ltime)
|
||||||
|
# "19"
|
||||||
|
# log.Ldate|log.Ltime|log.Lshortfile
|
||||||
|
# "23"
|
||||||
|
# log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile
|
||||||
log.trace.flags = 19
|
log.trace.flags = 19
|
||||||
log.info.flags = 19
|
log.info.flags = 19
|
||||||
log.warn.flags = 19
|
log.warn.flags = 19
|
||||||
@@ -169,6 +212,7 @@ log.error.flags = 19
|
|||||||
log.request.output = stderr
|
log.request.output = stderr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Section: prod
|
# Section: prod
|
||||||
# This section is evaluated when running Revel in production mode. Like so:
|
# This section is evaluated when running Revel in production mode. Like so:
|
||||||
@@ -176,18 +220,15 @@ log.request.output = stderr
|
|||||||
# See:
|
# See:
|
||||||
# [dev] section for documentation of the various settings
|
# [dev] section for documentation of the various settings
|
||||||
[prod]
|
[prod]
|
||||||
mode.dev = false
|
|
||||||
|
|
||||||
|
mode.dev = false
|
||||||
|
|
||||||
results.pretty = false
|
results.pretty = false
|
||||||
|
|
||||||
|
|
||||||
watch = false
|
watch = false
|
||||||
|
|
||||||
|
|
||||||
module.testrunner =
|
module.testrunner =
|
||||||
|
|
||||||
|
|
||||||
log.trace.output = off
|
log.trace.output = off
|
||||||
log.info.output = off
|
log.info.output = off
|
||||||
log.warn.output = log/%(app.name)s.log
|
log.warn.output = log/%(app.name)s.log
|
||||||
|
|||||||
Reference in New Issue
Block a user