QuickDID is a high-performance AT Protocol identity resolution service written in Rust. It provides handle-to-DID resolution with Redis-backed caching and queue processing.

feature: CORS headers and cleanup

Changed files
+45 -14
src
handle_resolver
http
+5 -3
src/handle_resolver/base.rs
··· 53 53 let did = resolve_subject(&self.http_client, &*self.dns_resolver, s) 54 54 .await 55 55 .map_err(|e| HandleResolverError::ResolutionFailed(e.to_string()))?; 56 - 56 + 57 57 let timestamp = SystemTime::now() 58 58 .duration_since(UNIX_EPOCH) 59 - .map_err(|e| HandleResolverError::ResolutionFailed(format!("System time error: {}", e)))? 59 + .map_err(|e| { 60 + HandleResolverError::ResolutionFailed(format!("System time error: {}", e)) 61 + })? 60 62 .as_secs(); 61 - 63 + 62 64 Ok((did, timestamp)) 63 65 } 64 66 }
+40 -11
src/http/handle_xrpc_resolve_handle.rs
··· 159 159 } 160 160 }; 161 161 162 - // Add Cache-Control header if configured 163 - if let Some(cache_control) = app_context.cache_control_header() { 164 - if let Ok(cache_control_value) = HeaderValue::from_str(cache_control) { 165 - response 166 - .headers_mut() 167 - .insert(header::CACHE_CONTROL, cache_control_value); 168 - } 169 - } 162 + let headers = response.headers_mut(); 170 163 171 164 // Add ETag header 172 165 match HeaderValue::from_str(&etag) { 173 166 Ok(etag_header_value) => { 174 - response 175 - .headers_mut() 176 - .insert(header::ETAG, etag_header_value); 167 + headers.insert(header::ETAG, etag_header_value); 177 168 } 178 169 Err(err) => { 179 170 tracing::error!(error = ?err, "unable to create etag response value"); 180 171 } 181 172 } 173 + 174 + // Add Cache-Control header if configured 175 + if let Some(cache_control) = app_context.cache_control_header() 176 + && let Ok(cache_control_value) = HeaderValue::from_str(cache_control) 177 + { 178 + headers.insert(header::CACHE_CONTROL, cache_control_value); 179 + } 180 + 181 + // Add CORS and Allow headers 182 + headers.insert("Allow", HeaderValue::from_static("GET, HEAD, OPTIONS")); 183 + headers.insert( 184 + header::ACCESS_CONTROL_ALLOW_HEADERS, 185 + HeaderValue::from_static("*"), 186 + ); 187 + headers.insert( 188 + header::ACCESS_CONTROL_ALLOW_METHODS, 189 + HeaderValue::from_static("GET, HEAD, OPTIONS"), 190 + ); 191 + headers.insert( 192 + header::ACCESS_CONTROL_ALLOW_ORIGIN, 193 + HeaderValue::from_static("*"), 194 + ); 195 + headers.insert( 196 + header::ACCESS_CONTROL_EXPOSE_HEADERS, 197 + HeaderValue::from_static("*"), 198 + ); 199 + headers.insert( 200 + header::ACCESS_CONTROL_MAX_AGE, 201 + HeaderValue::from_static("86400"), 202 + ); 203 + headers.insert( 204 + "Access-Control-Request-Headers", 205 + HeaderValue::from_static("*"), 206 + ); 207 + headers.insert( 208 + "Access-Control-Request-Method", 209 + HeaderValue::from_static("GET"), 210 + ); 182 211 183 212 Ok(response) 184 213 }