File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11package framework
22
3- import "github.com/studiolambda/cosmos/router"
3+ import (
4+ _ "github.com/studiolambda/cosmos/contract"
5+ _ "github.com/studiolambda/cosmos/problem"
6+ "github.com/studiolambda/cosmos/router"
7+ )
48
59// Router is the HTTP router type used by Cosmos applications.
610// It provides routing functionality with support for path parameters,
Original file line number Diff line number Diff line change @@ -4,10 +4,25 @@ import (
44 "net/http"
55
66 "github.com/studiolambda/cosmos/contract"
7+ "github.com/studiolambda/cosmos/problem"
78)
89
10+ var ErrSessionNotFound = problem.Problem {
11+ Title : "Session not found" ,
12+ Detail : "Unable to find the session in the request" ,
13+ Status : http .StatusInternalServerError ,
14+ }
15+
916func Session (r * http.Request , key any ) (contract.Session , bool ) {
1017 s , ok := r .Context ().Value (key ).(contract.Session )
1118
1219 return s , ok
1320}
21+
22+ func MustSession (r * http.Request , key any ) contract.Session {
23+ if s , ok := Session (r , key ); ok {
24+ return s
25+ }
26+
27+ panic (ErrSessionNotFound )
28+ }
You can’t perform that action at this time.
0 commit comments