Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
RequiredParam does not return output in format specificed by Render middleware
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
sent-hil  
View profile  
 More options Aug 20 2012, 5:13 am
From: sent-hil <senthil...@gmail.com>
Date: Mon, 20 Aug 2012 02:13:43 -0700 (PDT)
Local: Mon, Aug 20 2012 5:13 am
Subject: RequiredParam does not return output in format specificed by Render middleware

class UsersCreate < Goliath::API
  use Goliath::Rack::Render, 'json'
  use Goliath::Rack::Params
  use Goliath::Rack::Validation::RequiredParam, {:key          => 'token',

:message => 'is required'}
end

If no "token" param, Goliath returns "[:error, \"token is required\"]".
Since I've included the Render middleware, shouldn't the output be in json?

Regards.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ilya Grigorik  
View profile  
 More options Aug 20 2012, 1:36 pm
From: Ilya Grigorik <igrigo...@gmail.com>
Date: Mon, 20 Aug 2012 10:36:34 -0700
Local: Mon, Aug 20 2012 1:36 pm
Subject: Re: [goliath] RequiredParam does not return output in format specificed by Render middleware

On Mon, Aug 20, 2012 at 2:13 AM, sent-hil <senthil...@gmail.com> wrote:
> class UsersCreate < Goliath::API
>   use Goliath::Rack::Render, 'json'
>   use Goliath::Rack::Params
>   use Goliath::Rack::Validation::RequiredParam, {:key          => 'token',

> :message => 'is required'}
> end

> If no "token" param, Goliath returns "[:error, \"token is required\"]".
> Since I've included the Render middleware, shouldn't the output be in json?

Yes, but it also depends on what you're using to send the request.. If your
client is specifically asking for text/plain, then that's what you'll get.

ig


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sent-hil  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 1:54 pm
From: sent-hil <senthil...@gmail.com>
Date: Mon, 20 Aug 2012 10:54:02 -0700
Local: Mon, Aug 20 2012 1:54 pm
Subject: Re: [goliath] RequiredParam does not return output in format specificed by Render middleware

But if its blank I should get a json response right? I'm not seeing that.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Marden  
View profile   Translate to Translated (View Original)
 More options Aug 21 2012, 10:43 pm
From: Eric Marden <eric.mar...@gmail.com>
Date: Tue, 21 Aug 2012 21:43:59 -0500
Local: Tues, Aug 21 2012 10:43 pm
Subject: Re: [goliath] RequiredParam does not return output in format specificed by Render middleware
Goliath::Rack::Render only sets the Content-Type header (and sets the Vary header to the value of the Accept header in the request).

Use that with Goliath::Rack::Formatters::JSON to get closer to the results you want.

Keep in mind that these are mechanisms of Content Negotiation (http://en.wikipedia.org/wiki/Content_negotiation) and can depend on the Accept header being sent asking for `application/json` data to be returned.

--
Eric Marden
http://ericmarden.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sent-hil  
View profile  
 More options Aug 21 2012, 11:38 pm
From: sent-hil <senthil...@gmail.com>
Date: Tue, 21 Aug 2012 20:38:05 -0700
Local: Tues, Aug 21 2012 11:38 pm
Subject: Re: [goliath] RequiredParam does not return output in format specificed by Render middleware

class UsersCreate < Goliath::API
  use Goliath::Rack::Formatters::JSON
  use Goliath::Rack::Render, 'json'
  use Goliath::Rack::Params
  use Goliath::Rack::Validation::RequiredParam, {:key          => 'token',

:message => 'is required'}
  def response(env)
    [200, {'Content-Type' => 'application/json'}, {response: 'user
created'}]
  end
end

With the above code, if I do `curl -H "Accept:application/json" "
http://localhost:8000"` shouldn't I be seeing {'error' => 'token is
required'}? Instead I still see [:error, "token is required"].

I included JSON formatter and specified 'Accept' header, not sure what's
going on here.

Regards.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ilya Grigorik  
View profile  
 More options Aug 25 2012, 1:06 am
From: Ilya Grigorik <igrigo...@gmail.com>
Date: Fri, 24 Aug 2012 22:06:49 -0700 (PDT)
Local: Sat, Aug 25 2012 1:06 am
Subject: Re: [goliath] RequiredParam does not return output in format specificed by Render middleware

It looks like you're inserting two JSON middlewares in the chain.. which
leads to double encoding:
https://gist.github.com/3c6bc1c39635fda4585d (that works).

Interestingly enough, we did have a guard for duplicate middlewares in pre
1.0 release, but dropped that as part of refactoring.. May be worth taking
another look.

ig


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sent-hil  
View profile  
 More options Aug 25 2012, 4:25 pm
From: sent-hil <senthil...@gmail.com>
Date: Sat, 25 Aug 2012 13:25:42 -0700
Local: Sat, Aug 25 2012 4:25 pm
Subject: Re: [goliath] RequiredParam does not return output in format specificed by Render middleware

I originally had just the Render middleware with 'json' as arg and I got
the text response when calling with no "Accept" header.

I tried it again and it seems to work. Not sure what has changed in the
meantime.

Oh well, thanks for your time.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »