mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-13 19:35:27 +00:00
Compare commits
5 Commits
server-eng
...
v0.17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eda33eb71 | ||
|
|
1c5fb4a6f8 | ||
|
|
a699dab33d | ||
|
|
0381636044 | ||
|
|
fb3980ce9d |
@@ -47,12 +47,10 @@ type Harness struct {
|
|||||||
proxy *httputil.ReverseProxy
|
proxy *httputil.ReverseProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderError(iw http.ResponseWriter, ir *http.Request, err error) {
|
func renderError(w http.ResponseWriter, r *http.Request, err error) {
|
||||||
context := revel.NewGOContext(nil)
|
req, resp := revel.NewRequest(r), revel.NewResponse(w)
|
||||||
context.Request.SetRequest(ir)
|
c := revel.NewController(req, resp)
|
||||||
context.Response.SetResponse(iw)
|
c.RenderError(err).Apply(req, resp)
|
||||||
c := revel.NewController(context)
|
|
||||||
c.RenderError(err).Apply(c.Request, c.Response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeHTTP handles all requests.
|
// ServeHTTP handles all requests.
|
||||||
|
|||||||
@@ -160,20 +160,8 @@ 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,12 +89,7 @@ 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]
|
||||||
_, err := build.Import(args[0], "", build.FindOnly)
|
if _, err := build.Import(args[0], "", build.FindOnly); err == nil {
|
||||||
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,6 +29,7 @@ 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 )
|
||||||
@@ -42,9 +43,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.SetHttpHeader("X-Frame-Options", "SAMEORIGIN")
|
c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
|
||||||
c.Response.SetHttpHeader("X-XSS-Protection", "1; mode=block")
|
c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
|
||||||
c.Response.SetHttpHeader("X-Content-Type-Options", "nosniff")
|
c.Response.Out.Header().Add("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.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,8 +97,18 @@ func testApp(args []string) {
|
|||||||
defer cmd.Kill()
|
defer cmd.Kill()
|
||||||
revel.INFO.Printf("Testing %s (%s) in %s mode\n", revel.AppName, revel.ImportPath, mode)
|
revel.INFO.Printf("Testing %s (%s) in %s mode\n", revel.AppName, revel.ImportPath, mode)
|
||||||
|
|
||||||
|
var httpAddr = revel.HTTPAddr
|
||||||
|
if httpAddr == "" {
|
||||||
|
httpAddr = "127.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
var httpProto = "http"
|
||||||
|
if revel.HTTPSsl {
|
||||||
|
httpProto = "https"
|
||||||
|
}
|
||||||
|
|
||||||
// Get a list of tests
|
// Get a list of tests
|
||||||
var baseURL = fmt.Sprintf("http://127.0.0.1:%d", revel.HTTPPort)
|
var baseURL = fmt.Sprintf("%s://%s:%d", httpProto, httpAddr, revel.HTTPPort)
|
||||||
testSuites, _ := getTestsList(baseURL)
|
testSuites, _ := getTestsList(baseURL)
|
||||||
|
|
||||||
// If a specific TestSuite[.Method] is specified, only run that suite/test
|
// If a specific TestSuite[.Method] is specified, only run that suite/test
|
||||||
|
|||||||
Reference in New Issue
Block a user