Commit b8a2fe86 authored by zauberstuhl's avatar zauberstuhl

Remove redirects from API

This should be handle by the application server
parent 8697ebe6
...@@ -47,12 +47,13 @@ func (c ApiComment) Index() revel.Result { ...@@ -47,12 +47,13 @@ func (c ApiComment) Index() revel.Result {
func (c ApiComment) Create() revel.Result { func (c ApiComment) Create() revel.Result {
var ( var (
comment string comment, fields string
postID uint postID uint
post models.Post post models.Post
) )
c.Params.Bind(&comment, "comment") c.Params.Bind(&comment, "comment")
c.Params.Bind(&fields, "fields")
c.Params.Bind(&postID, "id") c.Params.Bind(&postID, "id")
user, err := models.CurrentUser(c.Params, c.Session) user, err := models.CurrentUser(c.Params, c.Session)
...@@ -77,7 +78,8 @@ func (c ApiComment) Create() revel.Result { ...@@ -77,7 +78,8 @@ func (c ApiComment) Create() revel.Result {
} }
go dispatcher.Run() go dispatcher.Run()
return c.Redirect("/") // XXX that should return the comment
return c.RenderJSON(post)
} }
func (c ApiComment) Show() revel.Result { func (c ApiComment) Show() revel.Result {
......
...@@ -65,11 +65,12 @@ func (p ApiPost) Index() revel.Result { ...@@ -65,11 +65,12 @@ func (p ApiPost) Index() revel.Result {
func (p ApiPost) Create() revel.Result { func (p ApiPost) Create() revel.Result {
var ( var (
post models.Post post models.Post
postText string postText, fields string
aspectID uint aspectID uint
) )
p.Params.Bind(&postText, "post") p.Params.Bind(&postText, "post")
p.Params.Bind(&fields, "fields")
p.Params.Bind(&aspectID, "aspectID") p.Params.Bind(&aspectID, "aspectID")
emptyPost, err := regexp.MatchString(`^\s*?$`, postText) emptyPost, err := regexp.MatchString(`^\s*?$`, postText)
...@@ -144,7 +145,8 @@ func (p ApiPost) Create() revel.Result { ...@@ -144,7 +145,8 @@ func (p ApiPost) Create() revel.Result {
} }
go dispatcher.Run() go dispatcher.Run()
return p.Redirect("/") return p.RenderJSON(
apiHelpers.SelectStructFields(post, fields))
} }
func (p ApiPost) Show(guid string) revel.Result { func (p ApiPost) Show(guid string) revel.Result {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment