How can I specify sinatra to return an empty body with status of 200?
I can do body ""
but is there a more explicit way of doing this?
From the documentation:
You can return any object that would either be a valid Rack response, Rack body object or HTTP status code:
- An Array with three elements: [status (Fixnum), headers (Hash), response body (responds to
#each
)]- An Array with two elements: [status (Fixnum), response body (responds to #each)]
- An object that responds to
#each
and passes nothing but strings to the given block- A Fixnum representing the status code
So returning either of
[200, {}, ['']]
[200, ['']]
['']
200
should do the trick.
In Setting Body, Status Code and Headers, the helper methods status
and body
(and headers
) are introduced:
get '/nothing' do
status 200
body ''
end