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

Allow Session to store values with a specified generic type V #21

Merged
merged 1 commit into from
Dec 31, 2022

Conversation

dghubble
Copy link
Owner

  • Session state is now a map[string]V instead of a map[string]any and uses a generics type parameter
    • Update Set, Get, and GetOk methods to use generic type V
    • Change Session to Session[V any] to specify the type of value stored in the Session
    • See updated usage docs for examples
  • Change Store to Store[V any] to specify the type of value stored in sessions
  • Change NewCookieStore to NewCookieStore[V any] to specify the type of value stored in sessions

If you prefer to continue storing a map with any values,

// Store[any]
store := NewCookieStore[any](cookieConfig, keyPairs...)

@dghubble dghubble changed the title Allow Session to store values with a specified type V Allow Session to store values with a specified generic type V Dec 31, 2022
* `Session` state is now a `map[string]V` instead of a `map[string]any`
and uses a generics type parameter
  * Update `Set`, `Get`, and `GetOk` methods to use generic type `V`
  * Change `Session` to `Session[V any]` to specify the type of value stored in the Session
  * See updated usage docs for examples
* Change `Store` to `Store[V any]` to specify the type of value stored in sessions
* Change `NewCookieStore` to `NewCookieStore[V any]` to specify the type of value stored in sessions

If you prefer to continue storing a map with `any` values,

```
// Store[any]
store := NewCookieStore[any](cookieConfig, keyPairs...)
```
@dghubble dghubble merged commit 14df01f into main Dec 31, 2022
@dghubble dghubble deleted the generics branch December 31, 2022 22:41
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

Successfully merging this pull request may close these issues.

1 participant