dxx / feignhttp Goto Github PK
View Code? Open in Web Editor NEW:toolbox: Declarative HTTP client for rust
Home Page: https://docs.rs/feignhttp
License: MIT License
:toolbox: Declarative HTTP client for rust
Home Page: https://docs.rs/feignhttp
License: MIT License
I stumbled onto an unsupported pattern that would be nice to support. I have a trait that can be implemented with get
attributes, which works fine:
trait SomeRequest {
async fn request(&self, id: &str) -> feignhttp::Result<String>;
}
#[derive(Feign)]
struct Struct;
impl SomeRequest for Struct {
#[get("/some/path/{id}")]
async fn request(&self, id: &str) -> feignhttp::Result<String> { }
}
But when I add a URL prefix with the feign
attribute, it expands to a normal impl
without the trait:
#[feign(url = "https://some.url")]
impl SomeRequest for Struct {
#[get("/some/path/{id}")]
async fn request(&self, id: &str) -> feignhttp::Result<String> { }
}
// Expands to...
impl Struct {
async fn request(&self, id: &str) -> feignhttp::Result<String> {
use feignhttp::FeignClient as _;
use std::collections::HashMap;
use feignhttp::{HttpClient, HttpConfig, HttpResponse, util};
// ...
}
}
A workaround is to supply the URL for every request, i.e. #[get(url = "https://some.url", path = "/some/path/{id}")]
Hi,
I was wondering how difficult it would be to enable templates like #[get("https://api.github.com/repos/{self.path}")]
.
This can be useful to not store URL's as const like the GITHUB example.
My usecase would be a bit more advanced, where a struct stores AUTH JWT's and adds the JWT as a header, which is stored in self.
What are your thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.