Add example + travis

This commit is contained in:
Vincent Prouillet 2015-11-02 20:34:11 +00:00
parent d29f670989
commit 3f9b05bbed
2 changed files with 34 additions and 0 deletions

10
.travis.yml Normal file
View File

@ -0,0 +1,10 @@
language: rust
rust:
- stable
- beta
- nightly
sudo: false
notifications:
email: false

24
examples/claims.rs Normal file
View File

@ -0,0 +1,24 @@
extern crate jwt;
extern crate rustc_serialize;
use rustc_serialize::{Encodable};
use jwt::{
Algorithm,
encode,
decode
};
#[derive(Debug, RustcEncodable, RustcDecodable)]
struct Claims {
sub: String,
company: String
}
fn main() {
let my_claims = Claims {
sub: "b@b.com".to_owned(),
company: "ACME".to_owned()
};
let token = encode::<Claims>(my_claims, "secret".to_owned(), Algorithm::HS256).unwrap();
let claims = decode::<Claims>(token.to_owned(), "secret".to_owned(), Algorithm::HS256);
}