Refactoring for Gin, NoSurf and SCS continues.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package middleware
|
||||
|
||||
// ToDo: will no doubt need to fix as now using new session not the olf gorilla one
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package middleware
|
||||
|
||||
// ToDo: make sure im using with gin
|
||||
import "net/http"
|
||||
|
||||
func EnforceHTTPS(next http.Handler, enabled bool) http.Handler {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package middleware
|
||||
|
||||
// ToDo: make sure im using with gin
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package middleware
|
||||
|
||||
// ToDo: make sure im using with gin not to be confused with gins recovery but may do the same?
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
18
internal/http/middleware/scs.go
Normal file
18
internal/http/middleware/scs.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alexedwards/scs/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Session(sm *scs.SessionManager) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
handler := sm.LoadAndSave(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
c.Request = r
|
||||
c.Next()
|
||||
}))
|
||||
handler.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package middleware
|
||||
|
||||
// ToDo: This is more than likele now redunant with the session change
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
Reference in New Issue
Block a user