urlshortener-rs

MIT licensed

A very simple urlshortener for Rust.

This library aims to implement as much URL shortener services as possible and to provide an interface as minimal and simple as possible.

Implementations

Currently the following URL shorteners are implemented:

With authentication:

Without authentication:

The following services are supported, but are discouraged from use, due to restrictions such as rate limits:

Usage

Without authentication

```rust extern crate urlshortener;

use urlshortener::UrlShortener;

fn main() { let us = UrlShortener::new().unwrap(); let longurl = "https://google.com"; println!("Short url for google: {:?}", us.trygenerate(long_url, None)); } ```

With authentication (Goo.Gl)

```rust extern crate urlshortener;

use urlshortener::{ UrlShortener, Provider };

fn main() { let us = UrlShortener::new().unwrap(); let longurl = "https://google.com"; let key = "MYAPIKEY"; println!("Short url for google: {:?}", us.generate(longurl, Provider::GooGl { apikey: key.toowned() })); } ```

Combined (Goo.Gl + Is.Gd)

```rust extern crate urlshortener;

use urlshortener::{ UrlShortener, Provider };

fn main() {
let us = UrlShortener::new().unwrap(); let providers = vec![ Provider::GooGl { apikey: "MYAPIKEY".toowned() }, Provider::IsGd, ]; let longurl = "https://rust-lang.org"; println!("Short url for google: {:?}", us.trygenerate(long_url, Some(providers))); } ```

License

This project is licensed under the MIT license.