refactor: rename internal/session package to internal/ctx

This commit is contained in:
Prad Nukala 2024-10-08 17:22:14 -04:00
parent 35348fef6a
commit 25cddbada6
11 changed files with 10 additions and 12 deletions

View File

@ -322,7 +322,7 @@ build-hway: gen-templ gen-pkl
build-motr: gen-templ gen-pkl
@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:
@echo "(nebula) Building nebula"

View File

@ -15,14 +15,14 @@ import (
"github.com/labstack/echo/v4"
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/worker"
)
func main() {
e := echo.New()
e.Use(session.UseSession)
e.Use(ctx.UseSession)
registerViews(e)
registerState(e)
Serve(e)

View File

@ -1,4 +1,4 @@
package session
package ctx
import (
"net/http"

View File

@ -1,10 +1,8 @@
package session
package ctx
import (
"github.com/labstack/echo/v4"
"github.com/segmentio/ksuid"
"github.com/onsonr/sonr/internal/headers"
)
// GetSession returns the current Session
@ -16,7 +14,7 @@ func GetSession(c echo.Context) *Session {
func UseSession(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
sc := initSession(c)
headers := new(headers.RequestHeaders)
headers := new(RequestHeaders)
err := sc.Bind(headers)
if err != nil {
return err

View File

@ -1,4 +1,4 @@
package headers
package ctx
type RequestHeaders struct {
CacheControl *string `header:"Cache-Control"`

View File

@ -1,4 +1,4 @@
package headers
package ctx
type ResponseHeaders struct {
// HTMX Specific

View File

@ -4,14 +4,14 @@ package main
import (
"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/syumai/workers"
)
func main() {
s := echo.New()
s.Use(session.UseSession)
s.Use(ctx.UseSession)
s.GET("/", routes.Home)
s.GET("/login", routes.LoginStart)