0adb8642 by astaxie

fix #270

同时支持全部小写和驼峰写法
1 parent d39954c9
Showing 1 changed file with 97 additions and 2 deletions
...@@ -96,89 +96,184 @@ func ParseConfig() (err error) { ...@@ -96,89 +96,184 @@ func ParseConfig() (err error) {
96 if v, err := AppConfig.Int("httpport"); err == nil { 96 if v, err := AppConfig.Int("httpport"); err == nil {
97 HttpPort = v 97 HttpPort = v
98 } 98 }
99 if v, err := AppConfig.Int("HttpPort"); err == nil {
100 HttpPort = v
101 }
99 if maxmemory, err := AppConfig.Int64("maxmemory"); err == nil { 102 if maxmemory, err := AppConfig.Int64("maxmemory"); err == nil {
100 MaxMemory = maxmemory 103 MaxMemory = maxmemory
101 } 104 }
105 if maxmemory, err := AppConfig.Int64("MaxMemory"); err == nil {
106 MaxMemory = maxmemory
107 }
102 AppName = AppConfig.String("appname") 108 AppName = AppConfig.String("appname")
109 if appname := AppConfig.String("AppName"); appname != "" {
110 AppName = appname
111 }
103 if runmode := AppConfig.String("runmode"); runmode != "" { 112 if runmode := AppConfig.String("runmode"); runmode != "" {
104 RunMode = runmode 113 RunMode = runmode
105 } 114 }
115 if runmode := AppConfig.String("RunMode"); runmode != "" {
116 RunMode = runmode
117 }
106 if autorender, err := AppConfig.Bool("autorender"); err == nil { 118 if autorender, err := AppConfig.Bool("autorender"); err == nil {
107 AutoRender = autorender 119 AutoRender = autorender
108 } 120 }
121 if autorender, err := AppConfig.Bool("AutoRender"); err == nil {
122 AutoRender = autorender
123 }
109 if autorecover, err := AppConfig.Bool("autorecover"); err == nil { 124 if autorecover, err := AppConfig.Bool("autorecover"); err == nil {
110 RecoverPanic = autorecover 125 RecoverPanic = autorecover
111 } 126 }
112 if pprofon, err := AppConfig.Bool("pprofon"); err == nil { 127 if autorecover, err := AppConfig.Bool("RecoverPanic"); err == nil {
113 PprofOn = pprofon 128 RecoverPanic = autorecover
114 } 129 }
115 if views := AppConfig.String("viewspath"); views != "" { 130 if views := AppConfig.String("viewspath"); views != "" {
116 ViewsPath = views 131 ViewsPath = views
117 } 132 }
133 if views := AppConfig.String("ViewsPath"); views != "" {
134 ViewsPath = views
135 }
118 if sessionon, err := AppConfig.Bool("sessionon"); err == nil { 136 if sessionon, err := AppConfig.Bool("sessionon"); err == nil {
119 SessionOn = sessionon 137 SessionOn = sessionon
120 } 138 }
139 if sessionon, err := AppConfig.Bool("SessionOn"); err == nil {
140 SessionOn = sessionon
141 }
121 if sessProvider := AppConfig.String("sessionprovider"); sessProvider != "" { 142 if sessProvider := AppConfig.String("sessionprovider"); sessProvider != "" {
122 SessionProvider = sessProvider 143 SessionProvider = sessProvider
123 } 144 }
145 if sessProvider := AppConfig.String("SessionProvider"); sessProvider != "" {
146 SessionProvider = sessProvider
147 }
124 if sessName := AppConfig.String("sessionname"); sessName != "" { 148 if sessName := AppConfig.String("sessionname"); sessName != "" {
125 SessionName = sessName 149 SessionName = sessName
126 } 150 }
151 if sessName := AppConfig.String("SessionName"); sessName != "" {
152 SessionName = sessName
153 }
127 if sesssavepath := AppConfig.String("sessionsavepath"); sesssavepath != "" { 154 if sesssavepath := AppConfig.String("sessionsavepath"); sesssavepath != "" {
128 SessionSavePath = sesssavepath 155 SessionSavePath = sesssavepath
129 } 156 }
157 if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" {
158 SessionSavePath = sesssavepath
159 }
130 if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 { 160 if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 {
131 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64) 161 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
132 SessionGCMaxLifetime = int64val 162 SessionGCMaxLifetime = int64val
133 } 163 }
164 if sessMaxLifeTime, err := AppConfig.Int("SessionGCMaxLifetime"); err == nil && sessMaxLifeTime != 0 {
165 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
166 SessionGCMaxLifetime = int64val
167 }
134 if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil { 168 if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil {
135 UseFcgi = usefcgi 169 UseFcgi = usefcgi
136 } 170 }
171 if usefcgi, err := AppConfig.Bool("UseFcgi"); err == nil {
172 UseFcgi = usefcgi
173 }
137 if enablegzip, err := AppConfig.Bool("enablegzip"); err == nil { 174 if enablegzip, err := AppConfig.Bool("enablegzip"); err == nil {
138 EnableGzip = enablegzip 175 EnableGzip = enablegzip
139 } 176 }
177 if enablegzip, err := AppConfig.Bool("EnableGzip"); err == nil {
178 EnableGzip = enablegzip
179 }
140 if directoryindex, err := AppConfig.Bool("directoryindex"); err == nil { 180 if directoryindex, err := AppConfig.Bool("directoryindex"); err == nil {
141 DirectoryIndex = directoryindex 181 DirectoryIndex = directoryindex
142 } 182 }
183 if directoryindex, err := AppConfig.Bool("DirectoryIndex"); err == nil {
184 DirectoryIndex = directoryindex
185 }
143 if hotupdate, err := AppConfig.Bool("hotupdate"); err == nil { 186 if hotupdate, err := AppConfig.Bool("hotupdate"); err == nil {
144 EnableHotUpdate = hotupdate 187 EnableHotUpdate = hotupdate
145 } 188 }
189 if hotupdate, err := AppConfig.Bool("HotUpdate"); err == nil {
190 EnableHotUpdate = hotupdate
191 }
146 if timeout, err := AppConfig.Int64("httpservertimeout"); err == nil { 192 if timeout, err := AppConfig.Int64("httpservertimeout"); err == nil {
147 HttpServerTimeOut = timeout 193 HttpServerTimeOut = timeout
148 } 194 }
195 if timeout, err := AppConfig.Int64("HttpServerTimeOut"); err == nil {
196 HttpServerTimeOut = timeout
197 }
149 if errorsshow, err := AppConfig.Bool("errorsshow"); err == nil { 198 if errorsshow, err := AppConfig.Bool("errorsshow"); err == nil {
150 ErrorsShow = errorsshow 199 ErrorsShow = errorsshow
151 } 200 }
201 if errorsshow, err := AppConfig.Bool("ErrorsShow"); err == nil {
202 ErrorsShow = errorsshow
203 }
152 if copyrequestbody, err := AppConfig.Bool("copyrequestbody"); err == nil { 204 if copyrequestbody, err := AppConfig.Bool("copyrequestbody"); err == nil {
153 CopyRequestBody = copyrequestbody 205 CopyRequestBody = copyrequestbody
154 } 206 }
207 if copyrequestbody, err := AppConfig.Bool("CopyRequestBody"); err == nil {
208 CopyRequestBody = copyrequestbody
209 }
155 if xsrfkey := AppConfig.String("xsrfkey"); xsrfkey != "" { 210 if xsrfkey := AppConfig.String("xsrfkey"); xsrfkey != "" {
156 XSRFKEY = xsrfkey 211 XSRFKEY = xsrfkey
157 } 212 }
213 if xsrfkey := AppConfig.String("XSRFKEY"); xsrfkey != "" {
214 XSRFKEY = xsrfkey
215 }
158 if enablexsrf, err := AppConfig.Bool("enablexsrf"); err == nil { 216 if enablexsrf, err := AppConfig.Bool("enablexsrf"); err == nil {
159 EnableXSRF = enablexsrf 217 EnableXSRF = enablexsrf
160 } 218 }
219 if enablexsrf, err := AppConfig.Bool("EnableXSRF"); err == nil {
220 EnableXSRF = enablexsrf
221 }
161 if expire, err := AppConfig.Int("xsrfexpire"); err == nil { 222 if expire, err := AppConfig.Int("xsrfexpire"); err == nil {
162 XSRFExpire = expire 223 XSRFExpire = expire
163 } 224 }
225 if expire, err := AppConfig.Int("XSRFExpire"); err == nil {
226 XSRFExpire = expire
227 }
164 if tplleft := AppConfig.String("templateleft"); tplleft != "" { 228 if tplleft := AppConfig.String("templateleft"); tplleft != "" {
165 TemplateLeft = tplleft 229 TemplateLeft = tplleft
166 } 230 }
231 if tplleft := AppConfig.String("TemplateLeft"); tplleft != "" {
232 TemplateLeft = tplleft
233 }
167 if tplright := AppConfig.String("templateright"); tplright != "" { 234 if tplright := AppConfig.String("templateright"); tplright != "" {
168 TemplateRight = tplright 235 TemplateRight = tplright
169 } 236 }
237 if tplright := AppConfig.String("TemplateRight"); tplright != "" {
238 TemplateRight = tplright
239 }
240 if httptls, err := AppConfig.Bool("httptls"); err == nil {
241 HttpTLS = httptls
242 }
170 if httptls, err := AppConfig.Bool("HttpTLS"); err == nil { 243 if httptls, err := AppConfig.Bool("HttpTLS"); err == nil {
171 HttpTLS = httptls 244 HttpTLS = httptls
172 } 245 }
246 if certfile := AppConfig.String("httpcertfile"); certfile != "" {
247 HttpCertFile = certfile
248 }
173 if certfile := AppConfig.String("HttpCertFile"); certfile != "" { 249 if certfile := AppConfig.String("HttpCertFile"); certfile != "" {
174 HttpCertFile = certfile 250 HttpCertFile = certfile
175 } 251 }
252 if keyfile := AppConfig.String("httpkeyfile"); keyfile != "" {
253 HttpKeyFile = keyfile
254 }
176 if keyfile := AppConfig.String("HttpKeyFile"); keyfile != "" { 255 if keyfile := AppConfig.String("HttpKeyFile"); keyfile != "" {
177 HttpKeyFile = keyfile 256 HttpKeyFile = keyfile
178 } 257 }
258 if serverName := AppConfig.String("beegoserverName"); serverName != "" {
259 BeegoServerName = serverName
260 }
179 if serverName := AppConfig.String("BeegoServerName"); serverName != "" { 261 if serverName := AppConfig.String("BeegoServerName"); serverName != "" {
180 BeegoServerName = serverName 262 BeegoServerName = serverName
181 } 263 }
264 if sd := AppConfig.String("staticdir"); sd != "" {
265 for k := range StaticDir {
266 delete(StaticDir, k)
267 }
268 sds := strings.Fields(sd)
269 for _, v := range sds {
270 if url2fsmap := strings.SplitN(v, ":", 2); len(url2fsmap) == 2 {
271 StaticDir["/"+url2fsmap[0]] = url2fsmap[1]
272 } else {
273 StaticDir["/"+url2fsmap[0]] = url2fsmap[0]
274 }
275 }
276 }
182 if sd := AppConfig.String("StaticDir"); sd != "" { 277 if sd := AppConfig.String("StaticDir"); sd != "" {
183 for k := range StaticDir { 278 for k := range StaticDir {
184 delete(StaticDir, k) 279 delete(StaticDir, k)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!