Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A very-very simple url shortener (client) for Rust.

License

NotificationsYou must be signed in to change notification settings

iddm/urlshortener-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crates badgeCIMIT licensed

A very simple urlshortener for Rust.

This library aims to implement as much URL shortener services as possible and to provide an interface asminimal and simple as possible. For easing pain with dependency hell, the library provides request objectssince 0.9.0 version which can be used for performing requests via user http-client library.

MSRV

The minimum supported rust version is bumped to 1.63 just because one of the dependencies.The code itself should work fine with Rust version 1.46, and, perhaps, even lower versions.

Implementations

Currently the following URL shorteners are implemented:

With authentication:

  • goo.gl
  • bit.ly
  • kutt.it (supports self hosting)

Without authentication:

  • bn.gy
  • is.gd
  • v.gd
  • bam.bz
  • fifo.cc
  • tiny.ph
  • tny.im
  • s.coop
  • bmeo.org
  • hmm.rs
  • url-shortener.io
  • biturl.top

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

  • tinyurl.com
  • psbe.co
  • rlu.ru
  • sirbz.com
  • hec.su
  • abv8.me
  • nowlinks.net

Usagewithout "client" feature

You can make aRequest object without "client" feature only via provider functions:

externcrate urlshortener;use urlshortener::providers::{Provider,self};fnmain(){let long_url ="https://google.com";let key ="MY_API_KEY";let req = providers::request(long_url,&Provider::GooGl{api_key: key.to_owned()});println!("A request object for shortening URL via GooGl: {:?}", req);}

Usage with "client" feature

Without authentication

externcrate urlshortener;use urlshortener::client::UrlShortener;fnmain(){let us =UrlShortener::new().unwrap();let long_url ="https://google.com";println!("Short url for google: {:?}", us.try_generate(long_url,None));}

With authentication (Goo.Gl)

externcrate urlshortener;use urlshortener::{ client::UrlShortener, providers::Provider};fnmain(){let us =UrlShortener::new().unwrap();let long_url ="https://google.com";let key ="MY_API_KEY";println!("Short url for google: {:?}", us.generate(long_url,Provider::GooGl{ api_key: key.to_owned()}));}

Combined (Goo.Gl +Is.Gd)

externcrate urlshortener;use urlshortener::{ client::UrlShortener, providers::Provider};fnmain(){let us =UrlShortener::new().unwrap();let providers =vec![Provider::GooGl{ api_key:"MY_API_KEY".to_owned()},Provider::IsGd,];let long_url ="https://rust-lang.org";println!("Short url for google: {:?}", us.try_generate(long_url,Some(providers)));}

License

This project islicensed under the MIT license.

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp