예제 #1
0
파일: test_helpers.go 프로젝트: o1egl/echo
func CookieTest(t *testing.T, coockie engine.Cookie) {
	assert.Equal(t, "github.com", coockie.Domain())
	assert.Equal(t, time.Date(2016, time.January, 1, 0, 0, 0, 0, time.UTC), coockie.Expires())
	assert.True(t, coockie.HTTPOnly())
	assert.True(t, coockie.Secure())
	assert.Equal(t, "session", coockie.Name())
	assert.Equal(t, "/", coockie.Path())
	assert.Equal(t, "securetoken", coockie.Value())
}
예제 #2
0
// SetCookie implements `engine.Response#SetCookie` function.
func (r *Response) SetCookie(c engine.Cookie) {
	cookie := new(fasthttp.Cookie)
	cookie.SetKey(c.Name())
	cookie.SetValue(c.Value())
	cookie.SetPath(c.Path())
	cookie.SetDomain(c.Domain())
	cookie.SetExpire(c.Expires())
	cookie.SetSecure(c.Secure())
	cookie.SetHTTPOnly(c.HTTPOnly())
	r.Response.Header.SetCookie(cookie)
}
예제 #3
0
파일: response.go 프로젝트: ZloyDyadka/echo
// SetCookie implements `engine.Response#SetCookie` function.
func (r *Response) SetCookie(c engine.Cookie) {
	http.SetCookie(r.ResponseWriter, &http.Cookie{
		Name:     c.Name(),
		Value:    c.Value(),
		Path:     c.Path(),
		Domain:   c.Domain(),
		Expires:  c.Expires(),
		Secure:   c.Secure(),
		HttpOnly: c.HTTPOnly(),
	})
}