Skip to content

Commit

Permalink
feat(doit): handle 'alt' param
Browse files Browse the repository at this point in the history
It's conditionally set to json, if we expect a response value.

Fixes #20
  • Loading branch information
Byron committed Mar 18, 2015
1 parent 29d9e45 commit 3ea5e19
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/mako/lib/mbuild.mako
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,12 @@ match result {
rtype = 'cmn::Result<hyper::client::Response>'
response_schema = method_response(c, m)
reserved_params = []
if response_schema:
rtype = 'cmn::Result<(hyper::client::Response, %s)>' % (response_schema.id)
reserved_params = ['alt']
possible_urls = [m.path]
simple_media_param = None
Expand Down Expand Up @@ -457,7 +461,10 @@ match result {
## "the trait `core::marker::Sized` is not implemented for the type `std::io::Read`"
use hyper::client::IntoBody;
use std::io::{Read, Seek};
let mut params: Vec<(&str, String)> = Vec::with_capacity(${len(params)} + ${paddfields}.len());
let mut params: Vec<(&str, String)> = Vec::with_capacity(${len(params) + len(reserved_params)} + ${paddfields}.len());
% if response_schema:
params.push(("alt", "json".to_string()));
% endif
% for p in field_params:
<%
pname = 'self.' + property(p.name) # property identifier
Expand Down Expand Up @@ -491,7 +498,7 @@ match result {
% endif
% endfor
## Additional params - may not overlap with optional params
for &field in [${', '.join(enclose_in('"', (p.name for p in field_params)))}].iter() {
for &field in [${', '.join(enclose_in('"', reserved_params + [p.name for p in field_params]))}].iter() {
if ${paddfields}.contains_key(field) {
return cmn::Result::FieldClash(field);
}
Expand Down Expand Up @@ -604,8 +611,6 @@ else {
}
let auth_header = hyper::header::Authorization(token.unwrap().access_token);
% endif
% if request_value and simple_media_param:
let mut request_value_reader = io::Cursor::new(json_encoded_request.clone().into_bytes());
let mut mp_reader: cmn::MultiPartReader = Default::default();
Expand Down

0 comments on commit 3ea5e19

Please sign in to comment.