Skip to content

Commit

Permalink
refactor: moved ExpiresAt field from cookies Attributes struct to Set…
Browse files Browse the repository at this point in the history
…Cookie function as a parameter
  • Loading branch information
ralvarezdev committed Feb 1, 2025
1 parent 7cdd75d commit f31aeab
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions http/cookie/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import (

// Attributes is the structure for the attributes of a cookie
type Attributes struct {
Name string
Path string
Domain string
ExpiresAt time.Time
Secure bool
HTTPOnly bool
SameSite http.SameSite
Name string
Path string
Domain string
Secure bool
HTTPOnly bool
SameSite http.SameSite
}

// SetCookie sets a cookie
func SetCookie(
w http.ResponseWriter,
attributes *Attributes,
value string,
expiresAt time.Time,
) {
// Create and create cookie
cookie := &http.Cookie{
Name: attributes.Name,
Value: value,
Path: attributes.Path,
Domain: attributes.Domain,
Expires: attributes.ExpiresAt,
Expires: expiresAt,
Secure: attributes.Secure,
HttpOnly: attributes.HTTPOnly,
SameSite: attributes.SameSite,
Expand Down

0 comments on commit f31aeab

Please sign in to comment.