boxdot / letterboxd-rs Goto Github PK
View Code? Open in Web Editor NEWLetterboxd API for access to data on the Letterboxd.com website in Rust.
License: Other
Letterboxd API for access to data on the Letterboxd.com website in Rust.
License: Other
Only integration tests without authentication should be executed.
The endpoint is a POST request without reponse body, which is different to other requests normally heaving a body reponse. Therefore, it does not fit to the POST macro. Also it is quite hard to write an integration test for this request without being banned from letterboxd.
It might be worth splitting up client.rs
and defs.rs
into sub-paths based on the endpoint type. I think that as the number of supported endpoints grows, keeping all the client code and struct definitions in single large files will start to get in the way: defs.rs
is already ~3k lines long.
The best way to do this IMO would be to pull out the client functions and struct defs into sub-paths based on the endpoint type (film, list, etc).
Example implementation
macro_rules! GET {
($func_name:ident, ($path:expr $(, $arg:ident:$T:ty)*), $ReqT:ty, $RespT:tt) => {
pub fn $func_name(&self $( , $arg: $T)*, req: &$ReqT) -> $RespT {
println!(
concat!("Called `{}` for path `", $path, "`"), stringify!($func_name) $( , $arg)*);
println!("{:?}", req);
$RespT { body: String::from("empty") }
}
};
($func_name:ident, $path:expr, $ReqT:ty, $RespT:tt) => {
GET!($func_name, ($path), $ReqT, $RespT);
};
}
#[derive(Debug)]
pub struct Request {
param: String,
}
pub struct Response {
body: String,
}
pub struct Client;
impl Client {
GET!(films, "/film", Request, Response);
GET!(film, ("/film/{}/title/{}", id: i32, name: &str), Request, Response);
}
fn main() {
Client.films(&Request { param: String::from("foo") });
Client.film(1, "foo", &Request { param: String::from("foo") });
}
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.