Skip to content

Commit

Permalink
update example to be more accurate for the struct
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaqx committed Jul 1, 2024
1 parent 47a9d3e commit 7a2d729
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/syntaqx/cookie"
)

type AccessTokenRequest struct {
type RequestCookies struct {
ApplicationID uuid.UUID `cookie:"Application-ID"`
AccessToken string `cookie:"Access-Token,signed"`
UserID int `cookie:"User-ID,signed"`
Expand All @@ -31,15 +31,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
}

// Populate struct from cookies
var req AccessTokenRequest
var req RequestCookies
err = cookie.PopulateFromCookies(r, &req)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

// Dump the struct as a response
fmt.Fprintf(w, "AccessTokenRequest: %+v", req)
fmt.Fprintf(w, "RequestCookies: %+v", req)
}

func setDemoCookies(w http.ResponseWriter) {
Expand Down

0 comments on commit 7a2d729

Please sign in to comment.