Skip to content

Commit d668b00

Browse files
committed
revel#1054 cross platform support
1 parent cdc3534 commit d668b00

File tree

7 files changed

+27
-29
lines changed

7 files changed

+27
-29
lines changed

fakeapp_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"io/ioutil"
55
"log"
66
"os"
7-
"path"
7+
"path/filepath"
88
"reflect"
99
)
1010

@@ -42,11 +42,11 @@ func (c Hotels) Index() Result {
4242
func (c Static) Serve(prefix, filepath string) Result {
4343
var basePath, dirName string
4444

45-
if !path.IsAbs(dirName) {
45+
if !filepath.IsAbs(dirName) {
4646
basePath = BasePath
4747
}
4848

49-
fname := path.Join(basePath, prefix, filepath)
49+
fname := filepath.Join(basePath, prefix, filepath)
5050
file, err := os.Open(fname)
5151
if os.IsNotExist(err) {
5252
return c.NotFound("")
@@ -66,7 +66,7 @@ func startFakeBookingApp() {
6666
WARN = TRACE
6767
ERROR = TRACE
6868

69-
MainTemplateLoader = NewTemplateLoader([]string{ViewsPath, path.Join(RevelPath, "templates")})
69+
MainTemplateLoader = NewTemplateLoader([]string{ViewsPath, filepath.Join(RevelPath, "templates")})
7070
MainTemplateLoader.Refresh()
7171

7272
RegisterController((*Hotels)(nil),

revel.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io/ioutil"
77
"log"
88
"os"
9-
"path"
109
"path/filepath"
1110
"runtime"
1211
"strings"
@@ -32,18 +31,18 @@ var (
3231
// App details
3332
AppName string // e.g. "sample"
3433
AppRoot string // e.g. "/app1"
35-
BasePath string // e.g. "/Users/robfig/gocode/src/corp/sample"
36-
AppPath string // e.g. "/Users/robfig/gocode/src/corp/sample/app"
37-
ViewsPath string // e.g. "/Users/robfig/gocode/src/corp/sample/app/views"
34+
BasePath string // e.g. "$GOPATH/src/corp/sample"
35+
AppPath string // e.g. "$GOPATH/src/corp/sample/app"
36+
ViewsPath string // e.g. "$GOPATH/src/corp/sample/app/views"
3837
ImportPath string // e.g. "corp/sample"
39-
SourcePath string // e.g. "/Users/robfig/gocode/src"
38+
SourcePath string // e.g. "$GOPATH/src"
4039

4140
Config *config.Context
4241
RunMode string // Application-defined (by default, "dev" or "prod")
4342
DevMode bool // if true, RunMode is a development mode.
4443

4544
// Revel installation details
46-
RevelPath string // e.g. "/Users/robfig/gocode/src/revel"
45+
RevelPath string // e.g. "$GOPATH/src/github.com/revel/revel"
4746

4847
// Where to look for templates
4948
// Ordered by priority. (Earlier paths take precedence over later paths.)
@@ -136,7 +135,7 @@ func Init(mode, importPath, srcPath string) {
136135
revelSourcePath, SourcePath = findSrcPaths(importPath)
137136
} else {
138137
// If the SourcePath was specified, assume both Revel and the app are within it.
139-
SourcePath = path.Clean(SourcePath)
138+
SourcePath = filepath.Clean(SourcePath)
140139
revelSourcePath = SourcePath
141140
packaged = true
142141
}
@@ -158,14 +157,14 @@ func Init(mode, importPath, srcPath string) {
158157
// 3. user supplied configs (...) - User configs can override/add any from above
159158
ConfPaths = append(
160159
[]string{
161-
path.Join(RevelPath, "conf"),
162-
path.Join(BasePath, "conf"),
160+
filepath.Join(RevelPath, "conf"),
161+
filepath.Join(BasePath, "conf"),
163162
},
164163
ConfPaths...)
165164

166165
TemplatePaths = []string{
167166
ViewsPath,
168-
path.Join(RevelPath, "templates"),
167+
filepath.Join(RevelPath, "templates"),
169168
}
170169

171170
// Load app.conf
@@ -343,7 +342,7 @@ func loadModules() {
343342
// Returns an error if the import path could not be found.
344343
func ResolveImportPath(importPath string) (string, error) {
345344
if packaged {
346-
return path.Join(SourcePath, importPath), nil
345+
return filepath.Join(SourcePath, importPath), nil
347346
}
348347

349348
modPkg, err := build.Import(importPath, "", build.FindOnly)

router.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"io/ioutil"
88
"net/http"
99
"net/url"
10-
"path"
10+
"path/filepath"
1111
"regexp"
1212
"strings"
1313

@@ -300,7 +300,7 @@ func getModuleRoutes(moduleName, joinedPath string, validate bool) ([]*Route, *E
300300
INFO.Println("Skipping routes for inactive module", moduleName)
301301
return nil, nil
302302
}
303-
return parseRoutesFile(path.Join(module.Path, "conf", "routes"), joinedPath, validate)
303+
return parseRoutesFile(filepath.Join(module.Path, "conf", "routes"), joinedPath, validate)
304304
}
305305

306306
// Groups:
@@ -422,7 +422,7 @@ func (router *Router) Reverse(action string, argValues map[string]string) *Actio
422422

423423
func init() {
424424
OnAppStart(func() {
425-
MainRouter = NewRouter(path.Join(BasePath, "conf", "routes"))
425+
MainRouter = NewRouter(filepath.Join(BasePath, "conf", "routes"))
426426
err := MainRouter.Refresh()
427427
if MainWatcher != nil && Config.BoolDefault("watch.routes", true) {
428428
MainWatcher.Listen(MainRouter, MainRouter.path)

server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55
"net/http/httptest"
66
"os"
7-
"path"
7+
"path/filepath"
88
"strings"
99
"testing"
1010
)
@@ -63,7 +63,7 @@ func TestFakeServer(t *testing.T) {
6363
resp.Body.Reset()
6464

6565
handle(resp, staticRequest)
66-
sessvarsSize := getFileSize(t, path.Join(BasePath, "public", "js", "sessvars.js"))
66+
sessvarsSize := getFileSize(t, filepath.Join(BasePath, "public", "js", "sessvars.js"))
6767
if int64(resp.Body.Len()) != sessvarsSize {
6868
t.Errorf("Expected sessvars.js to have %d bytes, got %d:\n%s", sessvarsSize, resp.Body.Len(), resp.Body)
6969
t.FailNow()

skeleton/conf/app.conf.template

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ http.ssl = false
3535
#http.sslkey =
3636

3737

38+
# Timeout specifies a time limit for request (in seconds) made by a single client.
39+
# A Timeout of zero means no timeout.
40+
timeout.read = 90
41+
timeout.write = 60
42+
43+
3844
# For any cookies set by Revel (Session,Flash,Error) these properties will set
3945
# the fields of:
4046
# http://golang.org/pkg/net/http/#Cookie
@@ -69,11 +75,6 @@ session.expires = 720h
6975
format.date = 2006-01-02
7076
format.datetime = 2006-01-02 15:04
7177

72-
# Timeout specifies a time limit for request (in seconds) made by a single client.
73-
# A Timeout of zero means no timeout.
74-
timeout.read = 90
75-
timeout.write = 60
76-
7778

7879
# Determines whether the template rendering should use chunked encoding.
7980
# Chunked encoding can decrease the time to first byte on the client side by

util_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package revel
22

33
import (
4-
"path"
54
"path/filepath"
65
"reflect"
76
"testing"
@@ -16,7 +15,7 @@ func TestContentTypeByFilename(t *testing.T) {
1615
"hello.world.c": "text/x-c; charset=utf-8",
1716
}
1817
srcPath, _ := findSrcPaths(REVEL_IMPORT_PATH)
19-
ConfPaths = []string{path.Join(
18+
ConfPaths = []string{filepath.Join(
2019
srcPath,
2120
filepath.FromSlash(REVEL_IMPORT_PATH),
2221
"conf"),

watcher.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package revel
22

33
import (
44
"os"
5-
"path"
65
"path/filepath"
76
"strings"
87
"sync"
@@ -191,7 +190,7 @@ func (w *Watcher) eagerRebuildEnabled() bool {
191190

192191
func (w *Watcher) rebuildRequired(ev fsnotify.Event, listener Listener) bool {
193192
// Ignore changes to dotfiles.
194-
if strings.HasPrefix(path.Base(ev.Name), ".") {
193+
if strings.HasPrefix(filepath.Base(ev.Name), ".") {
195194
return false
196195
}
197196

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy