Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwilemski committed Jan 6, 2024
1 parent 73479cd commit 82b7d67
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/handlers/micropub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ pub async fn handle_post(
) -> Result<impl IntoResponse, StatusCode> {
let content_type = headers.get("Content-Type");
let auth = headers.get("Authorization");
info!("micropub post headers: {:?}", headers);

if let None = auth {
return Err(StatusCode::FORBIDDEN);
Expand Down Expand Up @@ -555,6 +556,7 @@ pub async fn handle_post(
error!("error reading bytes from body: {:?}", e);
StatusCode::INTERNAL_SERVER_ERROR
})?;
info!("micropub post body: {:?}", body_bytes);
// if content type is json, attempt to decode and see whether this is an action (update/delete)
// or if it's a create.
if let Some(ct) = content_type {
Expand All @@ -565,6 +567,7 @@ pub async fn handle_post(
let json_parse_result: serde_json::Result<serde_json::Value> = serde_json::from_slice(body_byte_slice);
match json_parse_result {
Ok(json) => {
info!("micropub post body parsed json: {:?}", json);
if let Some(obj) = json.as_object() {
match obj.get("action") {
Some(serde_json::Value::String(action)) => {
Expand Down

0 comments on commit 82b7d67

Please sign in to comment.