This commit is contained in:
parent
fcd3d6ffca
commit
ac07105bf7
6 changed files with 87 additions and 29 deletions
|
@ -1,7 +1,5 @@
|
|||
use based::page::{Shell, render_page};
|
||||
use based::request::api::FallibleApiResponse;
|
||||
use based::request::{RawResponse, RequestContext, StringResponse, respond_with};
|
||||
use maud::html;
|
||||
use based::request::api::{FallibleApiResponse, api_error};
|
||||
use based::request::{RawResponse, RequestContext, respond_with};
|
||||
use rocket::http::{ContentType, Status};
|
||||
use rocket::tokio::io::AsyncReadExt;
|
||||
use rocket::{FromForm, get, post};
|
||||
|
@ -39,8 +37,12 @@ pub async fn tmp_file_to_vec<'r>(tmp: &TempFile<'r>) -> Vec<u8> {
|
|||
pub async fn upload_pkg(
|
||||
repo: &str,
|
||||
upload: Form<PkgUpload<'_>>,
|
||||
user: based::auth::User,
|
||||
user: based::auth::APIUser,
|
||||
) -> FallibleApiResponse {
|
||||
if !user.0.is_admin() {
|
||||
return Err(api_error("Forbidden"));
|
||||
}
|
||||
|
||||
let pkg = Package::new(repo, &upload.arch, &upload.name, &upload.version);
|
||||
|
||||
pkg.save(
|
||||
|
@ -101,18 +103,3 @@ pub async fn pkg_route(repo: &str, arch: &str, pkg_name: &str, ctx: RequestConte
|
|||
"Not found".as_bytes().to_vec(),
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn index_page(ctx: RequestContext) -> StringResponse {
|
||||
let content = html!(
|
||||
h1 { "Hello World!" };
|
||||
);
|
||||
|
||||
render_page(
|
||||
content,
|
||||
"Hello World",
|
||||
ctx,
|
||||
&Shell::new(html! {}, html! {}, Some(String::new())),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue