Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56381481
requests.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
requests.rs
View Options
//!
//! HTTP requests handled by the microservice.
//!
use
axum
::
http
::
StatusCode
;
use
limiting_factor_axum
::
api
::
replies
::{
ApiJsonResponse
,
ApiResponse
};
use
crate
::
registry
::{
Registry
,
Repository
};
pub
async
fn
status
()
->
&
'
static
str
{
"ALIVE"
}
// -------------------------------------------------------------
// /docker/registry
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pub
async
fn
get_registry_stats
()
->
ApiJsonResponse
<
Registry
>
{
Registry
::
with_default_location
()
.
into_json_response
()
}
// -------------------------------------------------------------
// /docker/registry/repository
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pub
async
fn
get_repository_info
(
repository_name
:
String
)
->
ApiJsonResponse
<
Repository
>
{
let
repository
=
Registry
::
with_default_location
()
.
get_repository
(
&
repository_name
);
match
repository
{
None
=>
Err
(
StatusCode
::
BAD_REQUEST
),
Some
(
repo
)
=>
{
if
repo
.
exists
()
{
Ok
(
repo
)
}
else
{
Err
(
StatusCode
::
NOT_FOUND
)
}
}
}.
into_json_response
()
}
pub
async
fn
get_all_repositories
()
->
ApiJsonResponse
<
Vec
<
Repository
>>
{
Registry
::
with_default_location
()
.
get_all_repositories
()
.
into_json_response
()
}
pub
async
fn
find_repository_by_layer
(
hash
:
String
)
->
ApiJsonResponse
<
Vec
<
Repository
>>
{
if
!
Repository
::
is_valid_hash
(
&
hash
)
{
return
Err
(
StatusCode
::
BAD_REQUEST
).
into_json_response
();
}
Registry
::
with_default_location
()
.
get_repositories_by_layer_hash
(
&
hash
)
.
into_json_response
()
}
pub
async
fn
find_repository_by_image
(
hash
:
String
)
->
ApiJsonResponse
<
Vec
<
Repository
>>
{
if
!
Repository
::
is_valid_hash
(
&
hash
)
{
return
Err
(
StatusCode
::
BAD_REQUEST
).
into_json_response
();
}
Registry
::
with_default_location
()
.
get_repositories_by_image_hash
(
&
hash
)
.
into_json_response
()
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 7, 15:25 (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4249541
Default Alt Text
requests.rs (1 KB)
Attached To
Mode
rAPIREG Nasqueron private Docker registry API
Attached
Detach File
Event Timeline
Log In to Comment