Comments (9)
I'm adding support for memcache, mysql, postgres, redis and sqlite3 👍
from fiber.
Hi @sachinbhutani, github.com/gofiber/session
is on our TODO list for v1.8.4+
from fiber.
@sachinbhutani, @koddr, @rezam90, @samuel-a-cooper I have been working on this for a while and I just released v0.0.1
, just wanted to give an update and feedback is welcome!
https://github.com/gofiber/session
My apologizes it took so long, I was really busy with other things for the past 2 weeks.
package main
import (
"fmt"
"github.com/gofiber/fiber"
"github.com/gofiber/session" // v0.0.1
)
func main() {
app := fiber.New()
// optional config
config := session.Config{
Key: "dinosaurus", // default: "sessionid"
Lookup: "header", // default: "cookie"
Domain: "google.com", // default: ""
Expires: 30 * time.Minutes, // default: 2 * time.Hour
Secure: true, // default: false
}
// create session handler
sessions := session.New(config)
app.Get("/", func(c *fiber.Ctx) {
store := sessions.Start(c) // get/create new session
store.ID() // returns session id
store.Empty() // empty storage
store.Destroy() // delete storage + cookie
store.Get("john") // get from storage
store.Regenerate() // generate new session id
store.Delete("john") // delete from storage
store.Set("john", "doe") // save to storage
store.Expires(2 * time.Hour) // set session expiration
})
app.Listen(3000)
}
from fiber.
awesome! is there's a way to extend the functionality to use a redis or other k/v stores ? or you recommend I write a new middleware module for it, like "session-redis" like yours ?
from fiber.
@thomasvvugt created a experimental storage provider
https://github.com/thomasvvugt/fiber-session
Not fully tested yet, feedback is welcome.
from fiber.
@Fenny and I are working a fresh version of the session middleware. Spoiler: We are providing the ability to implement multiple third party session providers! 🎉
from fiber.
can it be easy to implement just storage interface, and we can implement storage methods and use it with other storages without make pr to the repo and hard code it...
like here
type Config struct {
...
// Storage configs
Memcache StorageMemcache
MySQL StorageMySQL
// TODO: Add SQLite3 (compilation error)
Redis StorageRedis
Postgres StoragePostgres
}
or some registry with storage interface, if you want to use multiply storage ...
we can use Provider interface...
// Provider interface implemented by providers
type Provider interface {
Get(id []byte) ([]byte, error)
Save(id, data []byte, expiration time.Duration) error
Destroy(id []byte) error
Regenerate(id, newID []byte, expiration time.Duration) error
Count() int
NeedGC() bool
GC()
}
from fiber.
Hi @Shareed2k , thanks for your comment. We stuck with the interface option for now, we keep you all posted about our progress in the coming days!
from fiber.
@sachinbhutani @Shareed2k fiber/session supports multiple providers in v1.0.0
:
- memcache
- mysql
- postgres
- redis
- sqlite3
from fiber.
Related Issues (20)
- 🤗 [Question]: Fiber http with Cloudflare ssl reverse leading to 525, SSL handshake failed HOT 2
- 🤗 [Question] Is Fiber going to be used for Rust? HOT 3
- proxy.Balancer middleware should handle http backend servers when using app.ListenTLS HOT 2
- 🤗 [Question]: How to get the form data from the html form object? HOT 1
- 📝 [Proposal]: Add support for zstd compression
- 📝 [Proposal]: Add support for CHIPS (Cookies Having Independent Partitioned State)
- 🐛 [Bug]: incorrect selection of the error handler if one of the sub apps is mounted on "/" HOT 2
- 🤗 [Question]: gofiber v3 rc release date? HOT 2
- 📝 [Proposal]: v3 auto binding HOT 2
- 🤗 [Question]: Does fiber v3's Request not have the function of adding files to FormData? HOT 3
- 🤗 [Question]: I have a problem with Middleware HOT 10
- 🤗 [Question]: Is `fiber.Ctx` thread safe? If not, is that documented? HOT 8
- 🤗 [Question]: A new Redis key is created every time the url is accessed. Is this normal? HOT 5
- [question]: Why do long requests block each other? HOT 15
- 🐛 [Bug]: Limiter middleware with pebble storage does not deduct remaining limit
- 📝 [Proposal]: Improving route matching and url parsing performance with Ada Url HOT 7
- Improve Error Handling in CSRF Middleware Storage
- 🤗 [Question]: v3 when ready for production HOT 1
- 🐛 [Bug]: Unclear "json: invalid use of ,string struct tag, trying to unmarshal unquoted value into uint64" HOT 9
- 🤗 [Question]: Cache Next is not called when KeyGenerator is Defined HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.