Skip to content

Commit

Permalink
refactor: rename internal/session package to internal/ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
prnk28 committed Oct 8, 2024
1 parent 35348fe commit 25cddba
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions pkg/dwn/wasm/main.go → cmd/motr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/session/cookies.go → internal/ctx/cookies.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package session
package ctx

import (
"net/http"
Expand Down
6 changes: 2 additions & 4 deletions internal/session/middleware.go → internal/ctx/middleware.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/headers/request.go → internal/ctx/request.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package headers
package ctx

type RequestHeaders struct {
CacheControl *string `header:"Cache-Control"`
Expand Down
2 changes: 1 addition & 1 deletion internal/headers/response.go → internal/ctx/response.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package headers
package ctx

type ResponseHeaders struct {
// HTMX Specific
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 25cddba

Please sign in to comment.