diff options
Diffstat (limited to 'http/request/cookie.go')
-rw-r--r-- | http/request/cookie.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/http/request/cookie.go b/http/request/cookie.go new file mode 100644 index 0000000..88cc626 --- /dev/null +++ b/http/request/cookie.go @@ -0,0 +1,17 @@ +// Copyright 2018 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package request // import "miniflux.app/http/request" + +import "net/http" + +// CookieValue returns the cookie value. +func CookieValue(r *http.Request, name string) string { + cookie, err := r.Cookie(name) + if err == http.ErrNoCookie { + return "" + } + + return cookie.Value +} |