Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
e938876c
authored
2015-02-27 00:12:10 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix the cycle import
1 parent
6e9d2dc9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
context/context.go
controller.go
context/context.go
View file @
e938876
...
...
@@ -31,7 +31,6 @@ import (
"strings"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/utils"
)
...
...
@@ -56,13 +55,7 @@ func (ctx *Context) Redirect(status int, localurl string) {
// if beego.ErrorMaps exists, panic body.
func
(
ctx
*
Context
)
Abort
(
status
int
,
body
string
)
{
ctx
.
ResponseWriter
.
WriteHeader
(
status
)
// first panic from ErrorMaps, is is user defined error functions.
if
_
,
ok
:=
beego
.
ErrorMaps
[
body
];
ok
{
panic
(
body
)
}
// last panic user string
ctx
.
ResponseWriter
.
Write
([]
byte
(
body
))
panic
(
beego
.
USERSTOPRUN
)
}
// Write string to response body.
...
...
controller.go
View file @
e938876
...
...
@@ -270,16 +270,22 @@ func (c *Controller) Redirect(url string, code int) {
// Aborts stops controller handler and show the error data if code is defined in ErrorMap or code string.
func
(
c
*
Controller
)
Abort
(
code
string
)
{
status
,
err
:=
strconv
.
Atoi
(
code
)
if
err
==
nil
{
c
.
Ctx
.
Abort
(
status
,
code
)
}
else
{
c
.
Ctx
.
Abort
(
200
,
code
)
if
err
!=
nil
{
status
=
200
}
c
.
CustomAbort
(
status
,
code
)
}
// CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body.
func
(
c
*
Controller
)
CustomAbort
(
status
int
,
body
string
)
{
c
.
Ctx
.
Abort
(
status
,
body
)
c
.
Ctx
.
ResponseWriter
.
WriteHeader
(
status
)
// first panic from ErrorMaps, is is user defined error functions.
if
_
,
ok
:=
ErrorMaps
[
body
];
ok
{
panic
(
body
)
}
// last panic user string
c
.
Ctx
.
ResponseWriter
.
Write
([]
byte
(
body
))
panic
(
USERSTOPRUN
)
}
// StopRun makes panic of USERSTOPRUN error and go to recover function if defined.
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment