Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F995845
handle-response.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
handle-response.ts
View Options
import
{
App
,
Context
,
File
}
from
"../main"
;
import
{
NewSession
,
ResourceCreated
,
}
from
"../../common_lib/response/responses"
;
export
default
function
(
app
:
App
,
context
:
Context
,
h
:
any
)
{
const
config
=
app
.
ConfigManager
.
get
(
"www-server"
);
return
function
(
response
:
any
)
{
app
.
Logger
.
debug
(
"HANDLE RESPONSE"
,
"Handling response"
,
response
);
let
rep
=
null
;
if
(
response
instanceof
File
)
{
app
.
Logger
.
debug3
(
"HANDLE RESPONSE"
,
"Response is a file"
);
if
(
response
.
id
)
{
rep
=
h
.
file
(
response
.
getDataPath
(),
{
confine
:
false
});
}
else
{
rep
=
h
.
response
(
response
.
data
);
}
rep
.
type
(
response
.
getMimeType
()).
header
(
"Cache-Control"
,
"max-age=6000, must-revalidate"
);
}
else
if
(
response
instanceof
NewSession
)
{
app
.
Logger
.
debug
(
"HANDLE RESPONSE"
,
"Response is a new session"
);
rep
=
h
.
response
(
response
)
.
state
(
config
[
"session-cookie-name"
],
response
.
metadata
.
session_id
);
}
else
if
(
response
instanceof
ResourceCreated
)
{
app
.
Logger
.
debug
(
"HANDLE RESPONSE"
,
"Response is a new resource"
);
rep
=
h
.
response
(
response
).
code
(
201
);
}
else
{
if
(
response
?
.
serialize
)
{
response
=
response
.
serialize
();
}
app
.
Logger
.
debug
(
"HANDLE RESPONSE"
,
"Responding with"
,
response
,
4
);
rep
=
h
.
response
(
response
);
}
app
.
Logger
.
debug
(
"HANDLE RESPONSE"
,
"returning from handle_response"
);
return
rep
;
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Mon, Dec 23, 21:58 (18 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556975
Default Alt Text
handle-response.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment