提个需求,一边更好的支持restful #12

Closed
opened 2015-07-27 11:31:23 +00:00 by lunny · 0 comments
Owner

Author: @muei

目前tango不是能很好的实现直接返回状态码+数据的方式,比如 return 201,"some data".
我尝试了这样:

package main

import (
    "errors"
    "github.com/lunny/tango"
)

type Action struct {
    tango.Json
}

func (Action) Get() (int, interface{}) {
    if true {
        return 201, map[string]string{
            "say": "Hello tango!",
        }
    }
    return 500, errors.New("something error")
}

func main() {
    t := tango.Classic()
    t.Get("/", new(Action))
    t.Run()
}

返回为响应参数的第一个

Author: @muei 目前tango不是能很好的实现直接返回状态码+数据的方式,比如 `return 201,"some data"`. 我尝试了这样: ``` package main import ( "errors" "github.com/lunny/tango" ) type Action struct { tango.Json } func (Action) Get() (int, interface{}) { if true { return 201, map[string]string{ "say": "Hello tango!", } } return 500, errors.New("something error") } func main() { t := tango.Classic() t.Get("/", new(Action)) t.Run() } ``` 返回为响应参数的第一个
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/tango#12
No description provided.