Cosmetic changes

This commit is contained in:
Manu Mtz-Almeida 2015-04-07 12:27:23 +02:00
parent 3abeba82fc
commit ea962038e1
3 changed files with 10 additions and 12 deletions

View File

@ -7,7 +7,7 @@ package gin
import "log" import "log"
func IsDebugging() bool { func IsDebugging() bool {
return gin_mode == debugCode return ginMode == debugCode
} }
func debugRoute(httpMethod, absolutePath string, handlers []HandlerFunc) { func debugRoute(httpMethod, absolutePath string, handlers []HandlerFunc) {

6
gin.go
View File

@ -83,8 +83,7 @@ func (engine *Engine) reuseContext(c *Context) {
func (engine *Engine) LoadHTMLGlob(pattern string) { func (engine *Engine) LoadHTMLGlob(pattern string) {
if IsDebugging() { if IsDebugging() {
r := &render.HTMLDebugRender{Glob: pattern} engine.HTMLRender = &render.HTMLDebugRender{Glob: pattern}
engine.HTMLRender = r
} else { } else {
templ := template.Must(template.ParseGlob(pattern)) templ := template.Must(template.ParseGlob(pattern))
engine.SetHTMLTemplate(templ) engine.SetHTMLTemplate(templ)
@ -93,8 +92,7 @@ func (engine *Engine) LoadHTMLGlob(pattern string) {
func (engine *Engine) LoadHTMLFiles(files ...string) { func (engine *Engine) LoadHTMLFiles(files ...string) {
if IsDebugging() { if IsDebugging() {
r := &render.HTMLDebugRender{Files: files} engine.HTMLRender = &render.HTMLDebugRender{Files: files}
engine.HTMLRender = r
} else { } else {
templ := template.Must(template.ParseFiles(files...)) templ := template.Must(template.ParseFiles(files...))
engine.SetHTMLTemplate(templ) engine.SetHTMLTemplate(templ)

14
mode.go
View File

@ -22,8 +22,8 @@ const (
testCode = iota testCode = iota
) )
var gin_mode int = debugCode var ginMode int = debugCode
var mode_name string = DebugMode var modeName string = DebugMode
func init() { func init() {
value := os.Getenv(GIN_MODE) value := os.Getenv(GIN_MODE)
@ -37,17 +37,17 @@ func init() {
func SetMode(value string) { func SetMode(value string) {
switch value { switch value {
case DebugMode: case DebugMode:
gin_mode = debugCode ginMode = debugCode
case ReleaseMode: case ReleaseMode:
gin_mode = releaseCode ginMode = releaseCode
case TestMode: case TestMode:
gin_mode = testCode ginMode = testCode
default: default:
log.Panic("gin mode unknown: " + value) log.Panic("gin mode unknown: " + value)
} }
mode_name = value modeName = value
} }
func Mode() string { func Mode() string {
return mode_name return modeName
} }