File: via_kutt_custom_host_provider.rs

package info (click to toggle)
rust-urlshortener 3.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 4
file content (23 lines) | stat: -rw-r--r-- 547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Generate a short URL by specifying which provider to use.

extern crate urlshortener;

use urlshortener::client::UrlShortener;
use urlshortener::providers::Provider;

fn main() {
    let long_url = "https://doc.rust-lang.org/std/";

    let us = UrlShortener::new().unwrap();
    let key = "MY_API_KEY";
    let host = "https://example.com";
    let short_url = us.generate(
        long_url,
        &Provider::Kutt {
            api_key: key.into(),
            host: Some(host.into()),
        },
    );

    println!("{:?}", short_url);
}