示例#1
0
func (self ValidationError) Respond(c httpcontext.HTTPContextLogger) error {
	if self.Fields != nil {
		c.Resp().Header().Set("Content-Type", "application/json; charset=UTF-8")
	}
	if self.Status != 0 {
		c.Resp().WriteHeader(self.Status)
	}
	return json.NewEncoder(c.Resp()).Encode(self)
}
示例#2
0
文件: gae.go 项目: DaviWei/utils-1
func (self ErrNoSuchEntity) Respond(c httpcontext.HTTPContextLogger) (err error) {
	c.Resp().WriteHeader(404)
	_, err = fmt.Fprint(c.Resp(), self.Error())
	return
}