Add example + travis
This commit is contained in:
parent
d29f670989
commit
3f9b05bbed
|
@ -0,0 +1,10 @@
|
|||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
|
||||
sudo: false
|
||||
|
||||
notifications:
|
||||
email: false
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue