aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs7
-rw-r--r--src/post_routes.rs14
2 files changed, 12 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index a8e5552..01a893e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,7 @@ use sputnik::request::SputnikParts;
use sputnik::response::SputnikBuilder;
use std::convert::Infallible;
use std::env;
+use std::marker::PhantomData;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
@@ -361,6 +362,7 @@ async fn build_response<C: Controller>(
repo,
path: url_path,
branch: rev,
+ __: PhantomData::default(),
};
if !controller.may_read_path(&ctx, parts) {
@@ -474,13 +476,14 @@ fn action_links<C: Controller>(
out
}
-pub struct Context {
+pub struct Context<'a> {
repo: Repository,
branch: Branch,
path: Utf8PathBuf,
+ __: PhantomData<&'a ()>,
}
-impl Context {
+impl Context<'_> {
fn branch_head(&self) -> Result<Commit, Error> {
self.repo
.revparse_single(&self.branch.rev_str())
diff --git a/src/post_routes.rs b/src/post_routes.rs
index 51b35ec..3f8e5d1 100644
--- a/src/post_routes.rs
+++ b/src/post_routes.rs
@@ -28,7 +28,7 @@ pub(crate) async fn build_response<C: Controller>(
host: &HttpOrigin,
params: &ActionParam,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
body: Body,
parts: &mut Parts,
) -> Result<Response, Error> {
@@ -108,7 +108,7 @@ fn commit_file_update<C: Controller>(
async fn update_blob<C: Controller>(
body: Body,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
parts: &mut Parts,
) -> Result<Response, Error> {
if !controller.may_write_path(&ctx, parts) {
@@ -160,7 +160,7 @@ async fn update_blob<C: Controller>(
async fn upload_blob<C: Controller>(
body: Body,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
parts: &mut Parts,
) -> Result<Response, Error> {
if !controller.may_write_path(&ctx, parts) {
@@ -204,7 +204,7 @@ async fn upload_blob<C: Controller>(
async fn move_entry<C: Controller>(
body: Body,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
parts: &Parts,
) -> Result<Response, Error> {
if !controller.may_move_path(&ctx, parts) {
@@ -289,7 +289,7 @@ struct RemoveForm {
async fn remove_entry<C: Controller>(
body: Body,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
parts: &Parts,
) -> Result<Response, Error> {
if !controller.may_move_path(&ctx, parts) {
@@ -326,7 +326,7 @@ async fn remove_entry<C: Controller>(
async fn diff_blob<C: Controller>(
body: Body,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
parts: &Parts,
) -> Result<Response, Error> {
if !controller.may_write_path(&ctx, parts) {
@@ -355,7 +355,7 @@ async fn diff_blob<C: Controller>(
async fn preview_edit<C: Controller>(
body: Body,
controller: &C,
- ctx: Context,
+ ctx: Context<'_>,
parts: &Parts,
) -> Result<Response, Error> {
let form: EditForm = body.into_form().await?;