Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
eb0bc084
Commit
eb0bc084
authored
Jan 17, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
make the code mode readable
golint all the files
parents
48f19b41
f925bb90
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
47 additions
and
45 deletions
+47
-45
cache.go
cache/cache.go
+4
-3
file.go
cache/file.go
+4
-4
config.go
config.go
+8
-3
acceptencoder.go
context/acceptencoder.go
+1
-2
controller.go
controller.go
+2
-4
error.go
error.go
+1
-1
orm_querym2m.go
orm/orm_querym2m.go
+6
-6
router.go
router.go
+6
-6
sess_redis.go
session/redis/sess_redis.go
+1
-1
staticfile.go
staticfile.go
+4
-6
template.go
template.go
+1
-1
templatefunc.go
templatefunc.go
+2
-2
healthcheck.go
toolbox/healthcheck.go
+1
-1
statistics.go
toolbox/statistics.go
+1
-1
mail.go
utils/mail.go
+2
-2
util.go
validation/util.go
+2
-1
validators.go
validation/validators.go
+1
-1
No files found.
cache/cache.go
View file @
eb0bc084
...
...
@@ -67,14 +67,15 @@ type Cache interface {
StartAndGC
(
config
string
)
error
}
type
CacheInstance
func
()
Cache
// Instance is a function create a new Cache Instance
type
Instance
func
()
Cache
var
adapters
=
make
(
map
[
string
]
Cache
Instance
)
var
adapters
=
make
(
map
[
string
]
Instance
)
// Register makes a cache adapter available by the adapter name.
// If Register is called twice with the same name or if driver is nil,
// it panics.
func
Register
(
name
string
,
adapter
Cache
Instance
)
{
func
Register
(
name
string
,
adapter
Instance
)
{
if
adapter
==
nil
{
panic
(
"cache: Register adapter is nil"
)
}
...
...
cache/file.go
View file @
eb0bc084
...
...
@@ -39,10 +39,10 @@ type FileCacheItem struct {
// FileCache Config
var
(
FileCachePath
=
"cache"
// cache directory
FileCacheFileSuffix
=
".bin"
// cache file suffix
FileCacheDirectoryLevel
=
2
// cache file deep level if auto generated cache files.
FileCacheEmbedExpiry
time
.
Duration
=
0
// cache expire time, default is no expire forever.
FileCachePath
=
"cache"
// cache directory
FileCacheFileSuffix
=
".bin"
// cache file suffix
FileCacheDirectoryLevel
=
2
// cache file deep level if auto generated cache files.
FileCacheEmbedExpiry
time
.
Duration
// cache expire time, default is no expire forever.
)
// FileCache is cache adapter for file storage.
...
...
config.go
View file @
eb0bc084
...
...
@@ -25,7 +25,8 @@ import (
"github.com/astaxie/beego/utils"
)
type
BeegoConfig
struct
{
// BeegoConfig is the main struct for BConfig
type
Config
struct
{
AppName
string
//Application name
RunMode
string
//Running Mode: dev | prod
RouterCaseSensitive
bool
...
...
@@ -40,6 +41,7 @@ type BeegoConfig struct {
Log
LogConfig
}
// Listen holds for http and https related config
type
Listen
struct
{
Graceful
bool
// Graceful means use graceful module to start the server
ServerTimeOut
int64
...
...
@@ -59,6 +61,7 @@ type Listen struct {
EnableStdIo
bool
// EnableStdIo works with EnableFcgi Use FCGI via standard I/O
}
// WebConfig holds web related config
type
WebConfig
struct
{
AutoRender
bool
EnableDocs
bool
...
...
@@ -76,6 +79,7 @@ type WebConfig struct {
Session
SessionConfig
}
// SessionConfig holds session related config
type
SessionConfig
struct
{
SessionOn
bool
SessionProvider
string
...
...
@@ -87,6 +91,7 @@ type SessionConfig struct {
SessionDomain
string
}
// LogConfig holds Log related config
type
LogConfig
struct
{
AccessLogs
bool
FileLineNum
bool
...
...
@@ -95,7 +100,7 @@ type LogConfig struct {
var
(
// BConfig is the default config for Application
BConfig
*
Beego
Config
BConfig
*
Config
// AppConfig is the instance of Config, store the config information from file
AppConfig
*
beegoAppConfig
// AppConfigPath is the path to the config files
...
...
@@ -109,7 +114,7 @@ var (
)
func
init
()
{
BConfig
=
&
Beego
Config
{
BConfig
=
&
Config
{
AppName
:
"beego"
,
RunMode
:
DEV
,
RouterCaseSensitive
:
true
,
...
...
context/acceptencoder.go
View file @
eb0bc084
...
...
@@ -192,7 +192,6 @@ func parseEncoding(r *http.Request) string {
}
if
cf
,
ok
:=
encoderMap
[
lastQ
.
name
];
ok
{
return
cf
.
name
}
else
{
return
""
}
return
""
}
controller.go
View file @
eb0bc084
...
...
@@ -393,10 +393,8 @@ func (c *Controller) GetStrings(key string, def ...[]string) []string {
if
f
:=
c
.
Input
();
f
==
nil
{
return
defv
}
else
{
if
vs
:=
f
[
key
];
len
(
vs
)
>
0
{
return
vs
}
}
else
if
vs
:=
f
[
key
];
len
(
vs
)
>
0
{
return
vs
}
return
defv
...
...
error.go
View file @
eb0bc084
...
...
@@ -204,7 +204,7 @@ type errorInfo struct {
errorType
int
}
// map of http handlers for each error string.
//
ErrorMaps holds
map of http handlers for each error string.
// there is 10 kinds default error(40x and 50x)
var
ErrorMaps
=
make
(
map
[
string
]
*
errorInfo
,
10
)
...
...
orm/orm_querym2m.go
View file @
eb0bc084
...
...
@@ -42,18 +42,18 @@ func (o *queryM2M) Add(mds ...interface{}) (int64, error) {
dbase
:=
orm
.
alias
.
DbBaser
var
models
[]
interface
{}
var
other
_v
alues
[]
interface
{}
var
other
_n
ames
[]
string
var
other
V
alues
[]
interface
{}
var
other
N
ames
[]
string
for
_
,
colname
:=
range
mi
.
fields
.
dbcols
{
if
colname
!=
mfi
.
column
&&
colname
!=
rfi
.
column
&&
colname
!=
fi
.
mi
.
fields
.
pk
.
column
&&
mi
.
fields
.
columns
[
colname
]
!=
mi
.
fields
.
pk
{
other
_names
=
append
(
other_n
ames
,
colname
)
other
Names
=
append
(
otherN
ames
,
colname
)
}
}
for
i
,
md
:=
range
mds
{
if
reflect
.
Indirect
(
reflect
.
ValueOf
(
md
))
.
Kind
()
!=
reflect
.
Struct
&&
i
>
0
{
other
_values
=
append
(
other_v
alues
,
md
)
other
Values
=
append
(
otherV
alues
,
md
)
mds
=
append
(
mds
[
:
i
],
mds
[
i
+
1
:
]
...
)
}
}
...
...
@@ -94,8 +94,8 @@ func (o *queryM2M) Add(mds ...interface{}) (int64, error) {
values
=
append
(
values
,
v1
,
v2
)
}
names
=
append
(
names
,
other
_n
ames
...
)
values
=
append
(
values
,
other
_v
alues
...
)
names
=
append
(
names
,
other
N
ames
...
)
values
=
append
(
values
,
other
V
alues
...
)
return
dbase
.
InsertValue
(
orm
.
db
,
mi
,
true
,
names
,
values
)
}
...
...
router.go
View file @
eb0bc084
...
...
@@ -504,12 +504,12 @@ func (p *ControllerRegister) geturl(t *Tree, url, controllName, methodName strin
if
find
{
if
l
.
regexps
==
nil
{
if
len
(
l
.
wildcards
)
==
0
{
return
true
,
strings
.
Replace
(
url
,
"/"
+
urlPlaceholder
,
""
,
1
)
+
toU
rl
(
params
)
return
true
,
strings
.
Replace
(
url
,
"/"
+
urlPlaceholder
,
""
,
1
)
+
toU
RL
(
params
)
}
if
len
(
l
.
wildcards
)
==
1
{
if
v
,
ok
:=
params
[
l
.
wildcards
[
0
]];
ok
{
delete
(
params
,
l
.
wildcards
[
0
])
return
true
,
strings
.
Replace
(
url
,
urlPlaceholder
,
v
,
1
)
+
toU
rl
(
params
)
return
true
,
strings
.
Replace
(
url
,
urlPlaceholder
,
v
,
1
)
+
toU
RL
(
params
)
}
return
false
,
""
}
...
...
@@ -518,7 +518,7 @@ func (p *ControllerRegister) geturl(t *Tree, url, controllName, methodName strin
if
e
,
isok
:=
params
[
":ext"
];
isok
{
delete
(
params
,
":path"
)
delete
(
params
,
":ext"
)
return
true
,
strings
.
Replace
(
url
,
urlPlaceholder
,
p
+
"."
+
e
,
-
1
)
+
toU
rl
(
params
)
return
true
,
strings
.
Replace
(
url
,
urlPlaceholder
,
p
+
"."
+
e
,
-
1
)
+
toU
RL
(
params
)
}
}
}
...
...
@@ -539,7 +539,7 @@ func (p *ControllerRegister) geturl(t *Tree, url, controllName, methodName strin
return
false
,
""
}
}
return
true
,
url
+
toU
rl
(
params
)
return
true
,
url
+
toU
RL
(
params
)
}
var
i
int
var
startreg
bool
...
...
@@ -566,7 +566,7 @@ func (p *ControllerRegister) geturl(t *Tree, url, controllName, methodName strin
for
_
,
p
:=
range
ps
{
url
=
strings
.
Replace
(
url
,
urlPlaceholder
,
p
,
1
)
}
return
true
,
url
+
toU
rl
(
params
)
return
true
,
url
+
toU
RL
(
params
)
}
}
}
...
...
@@ -864,7 +864,7 @@ func (p *ControllerRegister) recoverPanic(context *beecontext.Context) {
}
}
func
toU
rl
(
params
map
[
string
]
string
)
string
{
func
toU
RL
(
params
map
[
string
]
string
)
string
{
if
len
(
params
)
==
0
{
return
""
}
...
...
session/redis/sess_redis.go
View file @
eb0bc084
...
...
@@ -45,7 +45,7 @@ import (
var
redispder
=
&
Provider
{}
// redis max pool size
//
MaxPoolSize
redis max pool size
var
MaxPoolSize
=
100
// SessionStore redis session store
...
...
staticfile.go
View file @
eb0bc084
...
...
@@ -16,6 +16,7 @@ package beego
import
(
"bytes"
"errors"
"net/http"
"os"
"path"
...
...
@@ -23,15 +24,12 @@ import (
"strconv"
"strings"
"sync"
"errors"
"time"
"github.com/astaxie/beego/context"
)
var
notStaticRequestErr
=
errors
.
New
(
"request not a static file request"
)
var
errNotStaticRequest
=
errors
.
New
(
"request not a static file request"
)
func
serverStaticRouter
(
ctx
*
context
.
Context
)
{
if
ctx
.
Input
.
Method
()
!=
"GET"
&&
ctx
.
Input
.
Method
()
!=
"HEAD"
{
...
...
@@ -39,7 +37,7 @@ func serverStaticRouter(ctx *context.Context) {
}
forbidden
,
filePath
,
fileInfo
,
err
:=
lookupFile
(
ctx
)
if
err
==
notStaticRequestErr
{
if
err
==
errNotStaticRequest
{
return
}
...
...
@@ -175,7 +173,7 @@ func searchFile(ctx *context.Context) (string, os.FileInfo, error) {
return
filePath
,
fi
,
err
}
}
return
""
,
nil
,
notStaticRequestErr
return
""
,
nil
,
errNotStaticRequest
}
// lookupFile find the file to serve
...
...
template.go
View file @
eb0bc084
...
...
@@ -50,7 +50,7 @@ func init() {
beegoTplFuncMap
[
"renderform"
]
=
RenderForm
beegoTplFuncMap
[
"assets_js"
]
=
AssetsJs
beegoTplFuncMap
[
"assets_css"
]
=
AssetsCSS
beegoTplFuncMap
[
"config"
]
=
Config
beegoTplFuncMap
[
"config"
]
=
Get
Config
beegoTplFuncMap
[
"map_get"
]
=
MapGet
// go1.2 added template funcs
...
...
templatefunc.go
View file @
eb0bc084
...
...
@@ -149,8 +149,8 @@ func NotNil(a interface{}) (isNil bool) {
return
CompareNot
(
a
,
nil
)
}
// Config get the Appconfig
func
Config
(
returnType
,
key
string
,
defaultVal
interface
{})
(
value
interface
{},
err
error
)
{
//
Get
Config get the Appconfig
func
Get
Config
(
returnType
,
key
string
,
defaultVal
interface
{})
(
value
interface
{},
err
error
)
{
switch
returnType
{
case
"String"
:
value
=
AppConfig
.
String
(
key
)
...
...
toolbox/healthcheck.go
View file @
eb0bc084
...
...
@@ -30,7 +30,7 @@
// more docs: http://beego.me/docs/module/toolbox.md
package
toolbox
// health checker map
//
AdminCheckList holds
health checker map
var
AdminCheckList
map
[
string
]
HealthChecker
// HealthChecker health checker interface
...
...
toolbox/statistics.go
View file @
eb0bc084
...
...
@@ -133,7 +133,7 @@ func (m *URLMap) GetMapData() []map[string]interface{} {
return
resultLists
}
// global statistics data map
//
StatisticsMap hosld
global statistics data map
var
StatisticsMap
*
URLMap
func
init
()
{
...
...
utils/mail.go
View file @
eb0bc084
...
...
@@ -103,8 +103,8 @@ func (e *Email) Bytes() ([]byte, error) {
}
e
.
Headers
.
Set
(
"Content-Type"
,
fmt
.
Sprintf
(
"multipart/mixed;
\r\n
boundary=%s
\r\n
"
,
w
.
Boundary
()))
fmt
.
Fprintf
(
w
,
"%s:"
,
"Content-Type"
)
fmt
.
Fprintf
(
w
,
" %s
\r\n
"
,
fmt
.
Sprintf
(
"multipart/mixed;
\r\n
boundary=%s
\r\n
"
,
w
.
Boundary
()))
fmt
.
Fprintf
(
buff
,
"%s:"
,
"Content-Type"
)
fmt
.
Fprintf
(
buff
,
" %s
\r\n
"
,
fmt
.
Sprintf
(
"multipart/mixed;
\r\n
boundary=%s
\r\n
"
,
w
.
Boundary
()))
// Start the multipart/mixed part
fmt
.
Fprintf
(
buff
,
"--%s
\r\n
"
,
w
.
Boundary
())
...
...
validation/util.go
View file @
eb0bc084
...
...
@@ -56,9 +56,10 @@ func init() {
}
}
// CustomFunc is for custom validate function
type
CustomFunc
func
(
v
*
Validation
,
obj
interface
{},
key
string
)
// Add a custom function to validation
// Add
CustomFunc Add
a custom function to validation
// The name can not be:
// Clear
// HasErrors
...
...
validation/validators.go
View file @
eb0bc084
...
...
@@ -46,7 +46,7 @@ var MessageTmpls = map[string]string{
"ZipCode"
:
"Must be valid zipcode"
,
}
// set default messages
//
SetDefaultMessage
set default messages
// if not set, the default messages are
// "Required": "Can not be empty",
// "Min": "Minimum is %d",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment