Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F11690954
requests.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
requests.rs
View Options
// -------------------------------------------------------------
// Alkane :: Server :: Requests
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Project: Nasqueron
// License: BSD-2-Clause
// -------------------------------------------------------------
use
limiting_factor
::
api
::
guards
::
RequestBody
;
use
limiting_factor
::
api
::
replies
::
{
ApiJsonResponse
,
ApiResponse
};
use
log
::
{
debug
,
info
,
warn
};
use
rocket
::
State
;
use
rocket_codegen
::
{
get
,
post
};
use
crate
::
actions
;
use
crate
::
config
::
AlkaneConfig
;
use
crate
::
runner
::
RecipeStatus
;
// -------------------------------------------------------------
// Monitoring
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#[get(
"/status"
)]
pub
fn
status
()
->
&
'
static
str
{
"ALIVE"
}
// -------------------------------------------------------------
// Alkane requests
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#[get(
"/is_present/<site_name>"
)]
pub
fn
is_present
(
site_name
:
String
,
config
:
State
<
AlkaneConfig
>
)
->
ApiJsonResponse
<
bool
>
{
actions
::
is_present
(
&
site_name
,
&
config
).
into_json_response
()
}
#[post(
"/init/<site_name>"
, data =
"<context>"
)]
pub
fn
init
(
site_name
:
String
,
context
:
RequestBody
,
config
:
State
<
AlkaneConfig
>
,
)
->
ApiJsonResponse
<
RecipeStatus
>
{
info
!
(
"Deploying {}"
,
&
site_name
);
let
context
=
context
.
into_optional_string
();
debug
!
(
"Context: {:?}"
,
&
context
);
match
actions
::
initialize
(
&
site_name
,
context
,
&
config
)
{
Ok
(
status
)
=>
status
.
into_json_response
(),
Err
(
error
)
=>
{
warn
!
(
"{}"
,
error
);
RecipeStatus
::
Error
.
into_json_response
()
}
}
}
#[post(
"/update/<site_name>"
, data =
"<context>"
)]
pub
fn
update
(
site_name
:
String
,
context
:
RequestBody
,
config
:
State
<
AlkaneConfig
>
,
)
->
ApiJsonResponse
<
RecipeStatus
>
{
info
!
(
"Deploying {}"
,
&
site_name
);
let
context
=
context
.
into_optional_string
();
debug
!
(
"Context: {:?}"
,
&
context
);
match
actions
::
update
(
&
site_name
,
context
,
&
config
)
{
Ok
(
status
)
=>
status
.
into_json_response
(),
Err
(
error
)
=>
{
warn
!
(
"{}"
,
error
);
RecipeStatus
::
Error
.
into_json_response
()
}
}
}
#[post(
"/deploy/<site_name>"
, data =
"<context>"
)]
pub
fn
deploy
(
site_name
:
String
,
context
:
RequestBody
,
config
:
State
<
AlkaneConfig
>
,
)
->
ApiJsonResponse
<
RecipeStatus
>
{
info
!
(
"Deploying {}"
,
&
site_name
);
let
context
=
context
.
into_optional_string
();
debug
!
(
"Context: {:?}"
,
&
context
);
match
actions
::
deploy
(
&
site_name
,
context
,
&
config
)
{
Ok
(
status
)
=>
status
.
into_json_response
(),
Err
(
error
)
=>
{
warn
!
(
"{}"
,
error
);
RecipeStatus
::
Error
.
into_json_response
()
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 12, 19:41 (6 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2978263
Default Alt Text
requests.rs (2 KB)
Attached To
Mode
rALK Alkane
Attached
Detach File
Event Timeline
Log In to Comment