alexedwards / scs

HTTP Session Management for Go
MIT License
2.02k stars 165 forks source link

Add automatic types registration functionality for gob encoding #176

Closed obanoff closed 10 months ago

obanoff commented 11 months ago

Added additional functionality to register types automatically for encoding/decoding, via gob package. Provide developers with a possibility to enable automatic gob types registration by changing SessionManager field AutoTypeRegistration to true (false by default). If enabled (true), upon each call to Put, it will checks whether a value type has been registered and added to SessionManager gobTypes string slice, otherwise gob.Resigter(value) will be called and the value type will be added to gobTypes slice. A bit of comfortability for simple tasks.

obanoff commented 10 months ago

Actually, it's possible to implement automatic registration of types for gob coding even for external session storages, but requires to store additional data (slice of reflect.Value) to restore types registered in gob package upon app's launching. In short, it brings many changes into existing code base. If it's a valuable idea for the project, I would be glad to start working on it.