Use Accept header instead of Content-Type header for client content negotiation
This commit is contained in:
parent
b2f4101a9c
commit
8403238dbb
4 changed files with 12 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::err::Error;
|
||||
use reqwest::blocking::Client;
|
||||
use reqwest::blocking::Response;
|
||||
use reqwest::header::CONTENT_TYPE;
|
||||
use reqwest::header::ACCEPT;
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::Editor;
|
||||
use serde_json::Value;
|
||||
|
@ -41,7 +41,7 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
|
|||
// Make a new remote request
|
||||
let res = Client::new()
|
||||
.post(&conn)
|
||||
.header(CONTENT_TYPE, "application/json")
|
||||
.header(ACCEPT, "application/json")
|
||||
.basic_auth(user, Some(pass));
|
||||
// Add NS header if specified
|
||||
let res = match ns {
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
.and(warp::path::end())
|
||||
.and(warp::post())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(warp::body::content_length_limit(MAX))
|
||||
.and(warp::body::bytes())
|
||||
.and_then(handler)
|
||||
|
|
|
@ -36,7 +36,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let select = warp::any()
|
||||
.and(warp::get())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String).and(warp::path::end()))
|
||||
.and(warp::query())
|
||||
.and_then(select_all);
|
||||
|
@ -44,7 +44,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let create = warp::any()
|
||||
.and(warp::post())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String).and(warp::path::end()))
|
||||
.and(warp::body::content_length_limit(MAX))
|
||||
.and(warp::body::bytes())
|
||||
|
@ -53,7 +53,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let delete = warp::any()
|
||||
.and(warp::delete())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String).and(warp::path::end()))
|
||||
.and_then(delete_all);
|
||||
// Specify route
|
||||
|
@ -67,14 +67,14 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let select = warp::any()
|
||||
.and(warp::get())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String / String).and(warp::path::end()))
|
||||
.and_then(select_one);
|
||||
// Set create method
|
||||
let create = warp::any()
|
||||
.and(warp::post())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String / String).and(warp::path::end()))
|
||||
.and(warp::body::content_length_limit(MAX))
|
||||
.and(warp::body::bytes())
|
||||
|
@ -83,7 +83,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let update = warp::any()
|
||||
.and(warp::put())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String / String).and(warp::path::end()))
|
||||
.and(warp::body::content_length_limit(MAX))
|
||||
.and(warp::body::bytes())
|
||||
|
@ -92,7 +92,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let modify = warp::any()
|
||||
.and(warp::patch())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String / String).and(warp::path::end()))
|
||||
.and(warp::body::content_length_limit(MAX))
|
||||
.and(warp::body::bytes())
|
||||
|
@ -101,7 +101,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let delete = warp::any()
|
||||
.and(warp::delete())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(path!("key" / String / String).and(warp::path::end()))
|
||||
.and_then(delete_one);
|
||||
// Specify route
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
|||
let post = base
|
||||
.and(warp::post())
|
||||
.and(session::build())
|
||||
.and(warp::header::<String>(http::header::CONTENT_TYPE.as_str()))
|
||||
.and(warp::header::<String>(http::header::ACCEPT.as_str()))
|
||||
.and(warp::body::content_length_limit(MAX))
|
||||
.and(warp::body::bytes())
|
||||
.and_then(handler);
|
||||
|
|
Loading…
Reference in a new issue