feat(server): add repository prefix path configuration and service struct
- Add REPO_PREFIX_PATH environment variable support in Dockerfile and main.rs - Introduce GitksService struct with repo_prefix field to manage repository paths - Implement resolve and resolve_for_init methods for repository path handling - Add path traversal protection and validation for repository operations - Update all service implementations to use self.resolve instead of global resolve - Modify serve function to accept repo_prefix parameter and pass to GitksService - Remove global resolve functions and integrate them into GitksService struct - Add proper initialization of repo directory from environment variable
This commit is contained in:
+3
-3
@@ -1,6 +1,6 @@
|
||||
use crate::pb::*;
|
||||
|
||||
use super::{GitksService, into_status, into_stream, resolve};
|
||||
use super::{GitksService, into_status, into_stream};
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl archive_service_server::ArchiveService for GitksService {
|
||||
@@ -12,7 +12,7 @@ impl archive_service_server::ArchiveService for GitksService {
|
||||
request: tonic::Request<ArchiveRequest>,
|
||||
) -> Result<tonic::Response<Self::GetArchiveStream>, tonic::Status> {
|
||||
let inner = request.into_inner();
|
||||
let gb = resolve(inner.repository.as_ref())?;
|
||||
let gb = self.resolve(inner.repository.as_ref())?;
|
||||
let chunks = gb.get_archive(inner).map_err(into_status)?;
|
||||
Ok(tonic::Response::new(into_stream(chunks)))
|
||||
}
|
||||
@@ -22,7 +22,7 @@ impl archive_service_server::ArchiveService for GitksService {
|
||||
request: tonic::Request<ListArchiveEntriesRequest>,
|
||||
) -> Result<tonic::Response<ListArchiveEntriesResponse>, tonic::Status> {
|
||||
let inner = request.into_inner();
|
||||
let gb = resolve(inner.repository.as_ref())?;
|
||||
let gb = self.resolve(inner.repository.as_ref())?;
|
||||
let resp = gb.list_archive_entries(inner).map_err(into_status)?;
|
||||
Ok(tonic::Response::new(resp))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user