mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-12 02:55:16 +00:00
Compare commits
17 Commits
app.conf-c
...
server-eng
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18e6b92704 | ||
|
|
49041fb83d | ||
|
|
f86def601d | ||
|
|
15875dc9a1 | ||
|
|
16f98f92e0 | ||
|
|
9de11613ce | ||
|
|
e1776bda3c | ||
|
|
32d1f12b51 | ||
|
|
d114a92b3d | ||
|
|
8bf654d8b0 | ||
|
|
79ed869901 | ||
|
|
d68b27ae81 | ||
|
|
ce84b78204 | ||
|
|
19ca52182d | ||
|
|
bd4663b651 | ||
|
|
3ba212afb4 | ||
|
|
d2b1730439 |
@@ -88,8 +88,9 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
|
||||
revel.ImportPath, appVersion, revel.ImportPath, buildTime)
|
||||
|
||||
// TODO remove version check for versionLinkerFlags after Revel becomes Go min version to go1.5
|
||||
goVersion, _ := strconv.ParseFloat(runtime.Version()[2:5], 64)
|
||||
if goVersion < 1.5 {
|
||||
goVersion, err := strconv.ParseFloat(runtime.Version()[2:5], 64)
|
||||
// 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\"",
|
||||
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) {
|
||||
alias, ok := aliases[importPath]
|
||||
alias, ok := aliases[importPath]
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
@@ -297,7 +298,7 @@ func addAlias(aliases map[string]string, importPath, pkgName string) {
|
||||
func makePackageAlias(aliases map[string]string, pkgName string) string {
|
||||
i := 0
|
||||
alias := pkgName
|
||||
for containsValue(aliases, alias) {
|
||||
for containsValue(aliases, alias) || alias=="revel" {
|
||||
alias = fmt.Sprintf("%s%d", pkgName, i)
|
||||
i++
|
||||
}
|
||||
|
||||
@@ -47,10 +47,12 @@ type Harness struct {
|
||||
proxy *httputil.ReverseProxy
|
||||
}
|
||||
|
||||
func renderError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
req, resp := revel.NewRequest(r), revel.NewResponse(w)
|
||||
c := revel.NewController(req, resp)
|
||||
c.RenderError(err).Apply(req, resp)
|
||||
func renderError(iw http.ResponseWriter, ir *http.Request, err error) {
|
||||
context := revel.NewGOContext(nil)
|
||||
context.Request.SetRequest(ir)
|
||||
context.Response.SetResponse(iw)
|
||||
c := revel.NewController(context)
|
||||
c.RenderError(err).Apply(c.Request, c.Response)
|
||||
}
|
||||
|
||||
// ServeHTTP handles all requests.
|
||||
|
||||
@@ -160,8 +160,20 @@ func ProcessSource(roots []string) (*SourceInfo, *revel.Error) {
|
||||
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.
|
||||
if len(pkgs) > 1 {
|
||||
for i := range pkgs {
|
||||
println("Found package ", i)
|
||||
}
|
||||
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]
|
||||
// 2. revel run [port]
|
||||
// 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
|
||||
inputArgs.ImportPath = args[0]
|
||||
} else if port, err := strconv.Atoi(args[0]); err == nil {
|
||||
|
||||
@@ -29,7 +29,6 @@ func init() {
|
||||
revel.ActionInvoker, // Invoke the action.
|
||||
}
|
||||
|
||||
|
||||
// register startup functions with OnAppStart
|
||||
// revel.DevMode and revel.RunMode only work inside of OnAppStart. See Example Startup Script
|
||||
// ( order dependent )
|
||||
@@ -43,9 +42,9 @@ func init() {
|
||||
// should probably also have a filter for CSRF
|
||||
// not sure if it can go in the same filter or not
|
||||
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
|
||||
c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
|
||||
c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
|
||||
c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")
|
||||
c.Response.SetHttpHeader("X-Frame-Options", "SAMEORIGIN")
|
||||
c.Response.SetHttpHeader("X-XSS-Protection", "1; mode=block")
|
||||
c.Response.SetHttpHeader("X-Content-Type-Options", "nosniff")
|
||||
|
||||
fc[0](c, fc[1:]) // Execute the next filter stage.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user