A fork of attic a self-hostable Nix Binary Cache server
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use common constant for X-Attic-Nar-Info header

+9 -7
+3
attic/src/api/v1/upload_path.rs
··· 5 5 use crate::hash::Hash; 6 6 use crate::nix_store::StorePathHash; 7 7 8 + /// Header containing the upload info. 9 + pub const ATTIC_NAR_INFO: &str = "X-Attic-Nar-Info"; 10 + 8 11 /// NAR information associated with a upload. 9 12 /// 10 13 /// This is JSON-serialized as the value of the `X-Attic-Nar-Info` header.
+2 -5
client/src/api/mod.rs
··· 16 16 use crate::version::ATTIC_DISTRIBUTOR; 17 17 use attic::api::v1::cache_config::{CacheConfig, CreateCacheRequest}; 18 18 use attic::api::v1::get_missing_paths::{GetMissingPathsRequest, GetMissingPathsResponse}; 19 - use attic::api::v1::upload_path::{UploadPathNarInfo, UploadPathResult}; 19 + use attic::api::v1::upload_path::{UploadPathNarInfo, UploadPathResult, ATTIC_NAR_INFO}; 20 20 use attic::cache::CacheName; 21 21 use attic::nix_store::StorePathHash; 22 22 ··· 177 177 let req = self 178 178 .client 179 179 .put(endpoint) 180 - .header( 181 - "X-Attic-Nar-Info", 182 - HeaderValue::from_str(&upload_info_json)?, 183 - ) 180 + .header(ATTIC_NAR_INFO, HeaderValue::from_str(&upload_info_json)?) 184 181 .header(USER_AGENT, HeaderValue::from_str(ATTIC_USER_AGENT)?) 185 182 .body(Body::wrap_stream(stream)); 186 183
+4 -2
server/src/api/v1/upload_path.rs
··· 32 32 use crate::error::{ErrorKind, ServerError, ServerResult}; 33 33 use crate::narinfo::Compression; 34 34 use crate::{RequestState, State}; 35 - use attic::api::v1::upload_path::{UploadPathNarInfo, UploadPathResult, UploadPathResultKind}; 35 + use attic::api::v1::upload_path::{ 36 + UploadPathNarInfo, UploadPathResult, UploadPathResultKind, ATTIC_NAR_INFO, 37 + }; 36 38 use attic::hash::Hash; 37 39 use attic::stream::StreamHasher; 38 40 use attic::util::Finally; ··· 116 118 ) -> ServerResult<Json<UploadPathResult>> { 117 119 let upload_info: UploadPathNarInfo = { 118 120 let header = headers 119 - .get("X-Attic-Nar-Info") 121 + .get(ATTIC_NAR_INFO) 120 122 .ok_or_else(|| ErrorKind::RequestError(anyhow!("X-Attic-Nar-Info must be set")))?; 121 123 122 124 serde_json::from_slice(header.as_bytes()).map_err(ServerError::request_error)?