Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Adding multiple values for Set-Cookie and allowing *http.Cookie type #1548

Open
linmeii opened this issue Nov 4, 2024 · 0 comments

Comments

@linmeii
Copy link

linmeii commented Nov 4, 2024

Hey, recently I came across an interesting problem.

One of the endpoints in my service needs to return two or more Set-Cookie cookies at the same time.
Currently there is no way to create multiple Set-Cookies at the same time, and any attempt to change the type to an array will raise an error such as:
unsupported type in header: []string

I have two suggestions:

  1. Let's add the possibility to apply an array type for the Set-Cookie type header
  2. Allow for passing *http.Cookie (and the array) the same as the request comes with *http.Cookie, this would unify the types coming in and out

Example response from documentation

type LoginResponse struct {
	SessionID string `header:"Set-Cookie"`
}

Example request from documentation

type MyAuthParams struct {
	SessionCookie *http.Cookie `cookie:"session"`
}

Example of how I would see the proposal to be integrated:

type Response struct {
	// example param with `header:"Set-Cookie"` as a string
	Cookie string `header:"Set-Cookie"`
	
	// example param with `header:"Set-Cookie"` as a []string
	Cookies []string `header:"Set-Cookie"`
	
	// example param with `header:"Set-Cookie"` as a *http.Cookie
	Cookie *http.Cookie `header:"Set-Cookie"`

        // example param with `header:"Set-Cookie"` as a []*http.Cookie
	 Cookies []*http.Cookie `header:"Set-Cookie"`
}

(obviously only one parameter with header:"Set-Cookie", just an example of multiple different types)

@linmeii linmeii changed the title Proposal: Adding multiple values for Set-Cookie and allow http.Cookie type Proposal: Adding multiple values for Set-Cookie and allowing *http.Cookie type Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant