1 Star 0 Fork 0

lunny/xweb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
errors.go 897 Bytes
一键复制 编辑 原始数据 按行查看 历史
lunny 提交于 2013-06-30 22:04 +08:00 . some improvement
package xweb
import (
"net/http"
)
type AbortError struct {
Code int
Content string
}
func (a *AbortError) Error() string {
return a.Content
}
/*func Error(w ResponseWriter, err error) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(code)
fmt.Fprintln(w, err)
}*/
func Abort(code int, content ...string) error {
if len(content) >= 1 {
return &AbortError{code, content[0]}
}
return &AbortError{code, statusText[code]}
}
func NotFound(content ...string) error {
return Abort(http.StatusNotFound)
}
func NotSupported(content ...string) error {
return Abort(http.StatusMethodNotAllowed)
}
func InterError(content ...string) error {
return Abort(http.StatusInternalServerError)
}
func Forbidden(content ...string) error {
return Abort(http.StatusForbidden)
}
func Unauthorized(content ...string) error {
return Abort(http.StatusUnauthorized)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lunny/xweb.git
git@gitee.com:lunny/xweb.git
lunny
xweb
xweb
master

搜索帮助