Skip to content

Commit

Permalink
Implement text (un)marshal for bearertoken.Token (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoylan authored and nmiyake committed Dec 30, 2018
1 parent f026ea9 commit d12f406
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bearertoken/bearertoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ package bearertoken
// Token represents a bearer token, generally sent by a REST client in a
// Authorization or Cookie header for authentication purposes.
type Token string

func (t Token) MarshalText() ([]byte, error) {
return []byte(t), nil
}

func (t *Token) UnmarshalText(text []byte) error {
*t = Token(text)
return nil
}

0 comments on commit d12f406

Please sign in to comment.