Remove api dependency on http package

This commit is contained in:
Seth Vargo
2015-04-23 19:58:44 -04:00
parent e1a6c7fdd9
commit 6a104b22db
2 changed files with 8 additions and 10 deletions

View File

@@ -8,10 +8,10 @@ import (
"net/url"
"os"
"time"
vaultHttp "github.com/hashicorp/vault/http"
)
const AuthCookieName = "token"
var (
errRedirect = errors.New("redirect")
)
@@ -104,7 +104,7 @@ func NewClient(c *Config) (*Client, error) {
func (c *Client) Token() string {
r := c.NewRequest("GET", "/")
for _, cookie := range c.config.HttpClient.Jar.Cookies(r.URL) {
if cookie.Name == vaultHttp.AuthCookieName {
if cookie.Name == AuthCookieName {
return cookie.Value
}
}
@@ -118,7 +118,7 @@ func (c *Client) SetToken(v string) {
r := c.NewRequest("GET", "/")
c.config.HttpClient.Jar.SetCookies(r.URL, []*http.Cookie{
&http.Cookie{
Name: vaultHttp.AuthCookieName,
Name: AuthCookieName,
Value: v,
Path: "/",
Expires: time.Now().Add(365 * 24 * time.Hour),
@@ -131,7 +131,7 @@ func (c *Client) ClearToken() {
r := c.NewRequest("GET", "/")
c.config.HttpClient.Jar.SetCookies(r.URL, []*http.Cookie{
&http.Cookie{
Name: vaultHttp.AuthCookieName,
Name: AuthCookieName,
Value: "",
Expires: time.Now().Add(-1 * time.Hour),
},