Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4ab2077

Browse files
committedFeb 27, 2023
Fix rebase issues
1 parent 691d297 commit 4ab2077

File tree

5 files changed

+36
-145
lines changed

5 files changed

+36
-145
lines changed
 

‎lib/src/db.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::{
2626
email::{self, MailMessage},
2727
endpoints::{default_endpoints, Endpoint, HandleGetContext},
2828
errors::{AtomicError, AtomicResult},
29-
plugins::default_endpoints,
3029
query::QueryResult,
3130
resources::PropVals,
3231
storelike::Storelike,

‎lib/src/endpoints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Examples of endpoints are versions for resources, or (pages for) collections.
44
//! See https://docs.atomicdata.dev/endpoints.html or https://atomicdata.dev/classes/Endpoint
55
6-
use crate::{errors::AtomicResult, urls, Db, Resource, Storelike, Value};
6+
use crate::{errors::AtomicResult, plugins, urls, Db, Resource, Storelike, Value};
77

88
/// The function that is called when a POST request matches the path
99
type HandleGet = fn(context: HandleGetContext) -> AtomicResult<Resource>;

‎lib/src/plugins/add_pubkey.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use serde::{Deserialize, Serialize};
88
use crate::{
99
agents::Agent,
1010
email::{EmailAddress, MailAction, MailMessage},
11-
endpoints::Endpoint,
11+
endpoints::{Endpoint, HandleGetContext},
1212
errors::AtomicResult,
1313
plugins::utils::return_success,
14-
urls, Db, Resource, Storelike,
14+
urls, Resource, Storelike,
1515
};
1616

1717
pub fn request_email_add_pubkey() -> Endpoint {
@@ -21,6 +21,7 @@ pub fn request_email_add_pubkey() -> Endpoint {
2121
description: "Requests an email to add a new PublicKey to an Agent.".to_string(),
2222
shortname: "request-pubkey-reset".to_string(),
2323
handle: Some(handle_request_email_pubkey),
24+
handle_post: None,
2425
}
2526
}
2627

@@ -31,6 +32,7 @@ pub fn confirm_add_pubkey() -> Endpoint {
3132
description: "Confirms a token to add a new Public Key.".to_string(),
3233
shortname: "request-pubkey-reset".to_string(),
3334
handle: Some(handle_confirm_add_pubkey),
35+
handle_post: None,
3436
}
3537
}
3638

@@ -39,11 +41,12 @@ struct AddPubkeyToken {
3941
agent: String,
4042
}
4143

42-
pub fn handle_request_email_pubkey(
43-
url: url::Url,
44-
store: &Db,
45-
_for_agent: Option<&str>,
46-
) -> AtomicResult<Resource> {
44+
pub fn handle_request_email_pubkey(context: HandleGetContext) -> AtomicResult<Resource> {
45+
let HandleGetContext {
46+
subject: url,
47+
store,
48+
for_agent: _,
49+
} = context;
4750
let mut email_option: Option<EmailAddress> = None;
4851
for (k, v) in url.query_pairs() {
4952
if let "email" = k.as_ref() {
@@ -96,12 +99,13 @@ pub fn handle_request_email_pubkey(
9699
return_success()
97100
}
98101

99-
#[tracing::instrument(skip(store))]
100-
pub fn handle_confirm_add_pubkey(
101-
url: url::Url,
102-
store: &Db,
103-
for_agent: Option<&str>,
104-
) -> AtomicResult<Resource> {
102+
#[tracing::instrument]
103+
pub fn handle_confirm_add_pubkey(context: HandleGetContext) -> AtomicResult<Resource> {
104+
let HandleGetContext {
105+
subject: url,
106+
store,
107+
for_agent: _,
108+
} = context;
105109
let mut token_opt: Option<String> = None;
106110
let mut pubkey_option = None;
107111

‎lib/src/plugins/reset_pubkey.rs

-130
This file was deleted.

‎server/src/helpers.rs

+18
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,21 @@ pub fn get_subject(
245245
let subject = format!("{}{}", server_without_last_slash, &req.uri().to_string());
246246
Ok(subject)
247247
}
248+
249+
/// Finds the extension
250+
pub fn try_extension(path: &str) -> Option<(ContentType, &str)> {
251+
let items: Vec<&str> = path.split('.').collect();
252+
if items.len() == 2 {
253+
let path = items[0];
254+
let content_type = match items[1] {
255+
"json" => ContentType::Json,
256+
"jsonld" => ContentType::JsonLd,
257+
"jsonad" => ContentType::JsonAd,
258+
"html" => ContentType::Html,
259+
"ttl" => ContentType::Turtle,
260+
_ => return None,
261+
};
262+
return Some((content_type, path));
263+
}
264+
None
265+
}

0 commit comments

Comments
 (0)
Please sign in to comment.