1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 04:21:57 +00:00

Add notes for the new lead maintainer of the open-source iris project and align with @get-ion/ion by @hiveminded

Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
This commit is contained in:
kataras
2017-07-10 18:32:42 +03:00
parent 2d4c2779a7
commit 9f85b74fc9
344 changed files with 4842 additions and 5174 deletions

View File

@@ -1,7 +1,3 @@
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sessions
import (
@@ -9,6 +5,8 @@ import (
"strconv"
"strings"
"time"
"github.com/kataras/iris/context"
)
var (
@@ -21,24 +19,27 @@ var (
// GetCookie returns cookie's value by it's name
// returns empty string if nothing was found
func GetCookie(name string, req *http.Request) string {
c, err := req.Cookie(name)
func GetCookie(ctx context.Context, name string) string {
c, err := ctx.Request().Cookie(name)
if err != nil {
return ""
}
return c.Value
// return ctx.GetCookie(name)
}
// AddCookie adds a cookie
func AddCookie(cookie *http.Cookie, res http.ResponseWriter) {
if v := cookie.String(); v != "" {
http.SetCookie(res, cookie)
}
func AddCookie(ctx context.Context, cookie *http.Cookie) {
// http.SetCookie(ctx.ResponseWriter(), cookie)
// ctx.Request().AddCookie(cookie)
ctx.SetCookie(cookie)
}
// RemoveCookie deletes a cookie by it's name/key
func RemoveCookie(name string, res http.ResponseWriter, req *http.Request) {
c, err := req.Cookie(name)
func RemoveCookie(ctx context.Context, name string) {
c, err := ctx.Request().Cookie(name)
if err != nil {
return
}
@@ -48,7 +49,7 @@ func RemoveCookie(name string, res http.ResponseWriter, req *http.Request) {
c.MaxAge = -1
c.Value = ""
c.Path = "/"
AddCookie(c, res)
AddCookie(ctx, c)
}
// IsValidCookieDomain returns true if the receiver is a valid domain to set