diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-09-23 21:02:26 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-09-23 21:02:26 -0700 |
commit | 9d08139f4363d3503398002bc82cb3746e3438cf (patch) | |
tree | b09c1efb14445624e4a2771bf8cbcf3a9828ecf9 /http/request/cookie.go | |
parent | 844680e57328034c20a2d2b84bd315b55fee9e23 (diff) |
Improve request package and add more unit tests
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 +} |