mirror of
https://github.com/kataras/iris.git
synced 2026-01-22 19:36:00 +00:00
add some MVC error handle examples
This commit is contained in:
@@ -72,6 +72,9 @@ type Result interface {
|
||||
//
|
||||
// The caller can manage it at the handler itself. However,
|
||||
// to reduce thoese type of duplications it's preferable to use such a standard interface instead.
|
||||
//
|
||||
// The Preflight method can return `iris.ErrStopExecution` to render
|
||||
// and override any interface that the structure value may implement, e.g. mvc.Result.
|
||||
type PreflightResult interface {
|
||||
Preflight(*context.Context) error
|
||||
}
|
||||
|
||||
@@ -223,7 +223,10 @@ func (r testPreflightResponse) Preflight(ctx iris.Context) error {
|
||||
return fmt.Errorf("custom error")
|
||||
}
|
||||
|
||||
ctx.StatusCode(r.Code)
|
||||
if r.Code > 0 {
|
||||
ctx.StatusCode(r.Code)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user