```rust,ignore
pub trait JWService {
type Err;
async fn login(&self, stuid: &str, password: &str) -> Result
The JWService
is implemented for all types which implements interfacer_http::HttpClient
.
You can refer to src/test.rs
for all use cases.
You can use this crate with client
feature, like this:
toml
zju-jw-scraper = { version = "0.2", features = ["client"] }
Then, you can use default client provided by interfacer-http-hyper
:
```rust,norun use zjujw_scraper::{client::client, JWService};
async fn testlogin() -> Result<(), Box
However, the default client can only handle requests on HTTP, if you want to use other protocol like HTTPS, you need other Connect
.
As the example connector
:
```rust,norun use hypertls::HttpsConnector; use zjujwscraper::{client::client_on, JWService};
async fn main() -> Result<(), Box
```
Run basic tests:
bash
cargo test
To test this crate fully, create a config file test-settings.toml
, and fill it referring to test-settings.toml.sample
. Then run tests:
bash
cargo test --all --all-features
As an alternative, you can configure tests using environment variables with prefix TEST_
.
bash
TEST_stu_id=3190000000 cargo test --all --all-features
Environment variables always have higher priority.