mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
refactor: rename internal/session package to internal/ctx
This commit is contained in:
parent
35348fef6a
commit
25cddbada6
2
Makefile
2
Makefile
@ -322,7 +322,7 @@ build-hway: gen-templ gen-pkl
|
|||||||
|
|
||||||
build-motr: gen-templ gen-pkl
|
build-motr: gen-templ gen-pkl
|
||||||
@echo "(dwn) Building motr.wasm -> Service Worker IPFS Vault"
|
@echo "(dwn) Building motr.wasm -> Service Worker IPFS Vault"
|
||||||
GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./pkg/dwn/wasm/main.go
|
GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./cmd/motr/main.go
|
||||||
|
|
||||||
build-nebula:
|
build-nebula:
|
||||||
@echo "(nebula) Building nebula"
|
@echo "(nebula) Building nebula"
|
||||||
|
@ -15,14 +15,14 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
promise "github.com/nlepage/go-js-promise"
|
promise "github.com/nlepage/go-js-promise"
|
||||||
|
|
||||||
"github.com/onsonr/sonr/internal/session"
|
"github.com/onsonr/sonr/internal/ctx"
|
||||||
"github.com/onsonr/sonr/pkg/nebula/routes"
|
"github.com/onsonr/sonr/pkg/nebula/routes"
|
||||||
"github.com/onsonr/sonr/pkg/nebula/worker"
|
"github.com/onsonr/sonr/pkg/nebula/worker"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
e.Use(session.UseSession)
|
e.Use(ctx.UseSession)
|
||||||
registerViews(e)
|
registerViews(e)
|
||||||
registerState(e)
|
registerState(e)
|
||||||
Serve(e)
|
Serve(e)
|
@ -1,4 +1,4 @@
|
|||||||
package session
|
package ctx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,10 +1,8 @@
|
|||||||
package session
|
package ctx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/segmentio/ksuid"
|
"github.com/segmentio/ksuid"
|
||||||
|
|
||||||
"github.com/onsonr/sonr/internal/headers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSession returns the current Session
|
// GetSession returns the current Session
|
||||||
@ -16,7 +14,7 @@ func GetSession(c echo.Context) *Session {
|
|||||||
func UseSession(next echo.HandlerFunc) echo.HandlerFunc {
|
func UseSession(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
sc := initSession(c)
|
sc := initSession(c)
|
||||||
headers := new(headers.RequestHeaders)
|
headers := new(RequestHeaders)
|
||||||
err := sc.Bind(headers)
|
err := sc.Bind(headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
@ -1,4 +1,4 @@
|
|||||||
package headers
|
package ctx
|
||||||
|
|
||||||
type RequestHeaders struct {
|
type RequestHeaders struct {
|
||||||
CacheControl *string `header:"Cache-Control"`
|
CacheControl *string `header:"Cache-Control"`
|
@ -1,4 +1,4 @@
|
|||||||
package headers
|
package ctx
|
||||||
|
|
||||||
type ResponseHeaders struct {
|
type ResponseHeaders struct {
|
||||||
// HTMX Specific
|
// HTMX Specific
|
@ -4,14 +4,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/onsonr/sonr/internal/session"
|
"github.com/onsonr/sonr/internal/ctx"
|
||||||
"github.com/onsonr/sonr/pkg/nebula/routes"
|
"github.com/onsonr/sonr/pkg/nebula/routes"
|
||||||
"github.com/syumai/workers"
|
"github.com/syumai/workers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := echo.New()
|
s := echo.New()
|
||||||
s.Use(session.UseSession)
|
s.Use(ctx.UseSession)
|
||||||
|
|
||||||
s.GET("/", routes.Home)
|
s.GET("/", routes.Home)
|
||||||
s.GET("/login", routes.LoginStart)
|
s.GET("/login", routes.LoginStart)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user