返回值
返回string,将会把string转为[]byte同时写入到ResponseWriter[]byte
返回[]byte将会直接写入ResponseWriterAbortError
如果返回AbortError, 则写入返回头AbortError.Code,内容为AbortError.Error()
如果包含了匿名结构体 tango.JSON
或者 tango.XML
,则返回值的行为将会发生变化:
map
, ,structs
返回值为map,如果是Json,则会自动序列化为Json格式。
例子代码如下:
type Action struct {
}
var i int
func (Action) Get() (int, interface{}) {
if i == 0 {
return 200, map[string]interface{}{"i":i}
return 500, errors.New("could not visit")
}
func main() {
t := tango.Classic()
t.Any("/", new(Action))