Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F5665585
match-policy.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
415 B
Referenced Files
None
Subscribers
None
match-policy.ts
View Options
import
{
Middleware
}
from
"koa"
;
import
Policy
from
"../chip-types/policy"
;
export
default
function
MatchPolicy
(
policy
:
Policy
)
:
Middleware
{
return
async
function
(
ctx
,
next
)
{
const
result
=
await
policy
.
check
(
ctx
.
$context
);
if
(
!
result
)
{
ctx
.
body
=
"Not allowed"
;
ctx
.
status
=
403
;
return
;
}
if
(
!
result
.
allowed
)
{
ctx
.
body
=
result
.
reason
;
ctx
.
status
=
403
;
}
await
next
();
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Jun 7, 23:21 (5 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
663325
Default Alt Text
match-policy.ts (415 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment