Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2572360
assets.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
763 B
Referenced Files
None
Subscribers
None
assets.rs
View Options
use
rocket
::{
http
::
ContentType
,
request
::
Request
,
response
::{
self
,
Responder
},
};
use
std
::{
io
,
path
::
PathBuf
};
#[derive(Debug)]
pub
struct
NamedFile
(
PathBuf
,
String
);
impl
NamedFile
{
pub
async
fn
send
(
name
:
String
,
contents
:
Option
<&
str
>
)
->
io
::
Result
<
NamedFile
>
{
Ok
(
NamedFile
(
PathBuf
::
from
(
name
),
contents
.
unwrap
().
to_string
()))
}
}
impl
<'
r
>
Responder
<'
r
,
'
static
>
for
NamedFile
{
fn
respond_to
(
self
,
req
:
&
'
r
Request
<'
_
>
)
->
response
::
Result
<'
static
>
{
let
mut
response
=
self
.
1.
respond_to
(
req
)
?
;
if
let
Some
(
ext
)
=
self
.
0.
extension
()
{
if
let
Some
(
ct
)
=
ContentType
::
from_extension
(
&
ext
.
to_string_lossy
())
{
response
.
set_header
(
ct
);
}
}
Ok
(
response
)
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 16, 12:07 PM (1 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
484777
Default Alt Text
assets.rs (763 B)
Attached To
Mode
rPMC Process Management Controller
Attached
Detach File
Event Timeline
Log In to Comment