Skip to content

Commit

Permalink
Bump dependencies: update bon to 3.0.1, serde to 1.0.215, and add pre…
Browse files Browse the repository at this point in the history
…ttyplease

Add metadata and debug methods to EndpointBuilder for enhanced functionality
  • Loading branch information
SteelAlloy committed Nov 19, 2024
1 parent 6808287 commit 46633ef
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
32 changes: 22 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ thiserror = "2.0.3"
hmac = "0.12.1"
sha1 = "0.10.6"
base64ct = { version = "1.6.0", features = ["alloc"] }
bon = "2.3.0"
bon = "3.0.1"
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.133"
36 changes: 36 additions & 0 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
metadata::Operation,
server::Server,
};
use endpoint_builder::{IsUnset, SetResponse, State};
use filter::Filter;

mod builder;
Expand Down Expand Up @@ -287,6 +288,41 @@ pub struct Endpoint {
smart: bool,
}

impl<S: State> EndpointBuilder<S> {
/// The metadata endpoint has **ALL** the options that the image one has,
/// but instead of actually performing the operations in the image, it just simulates the operations.
///
/// ```
/// let server = thumbor::Server::new_unsafe("http://localhost:8888");
///
/// let endpoint = server.endpoint_builder()
/// .metadata()
/// .build();
/// ```
pub fn metadata(self) -> EndpointBuilder<SetResponse<S>>
where
S::Response: IsUnset,
{
self.response(ResponseMode::Metadata)
}

/// The debug endpoint helps debug focal points by drawing a rectangle around them.
///
/// ```
/// let server = thumbor::Server::new_unsafe("http://localhost:8888");
///
/// let endpoint = server.endpoint_builder()
/// .debug()
/// .build();
/// ```
pub fn debug(self) -> EndpointBuilder<SetResponse<S>>
where
S::Response: IsUnset,
{
self.response(ResponseMode::Debug)
}
}

pub fn endpoint_from_operations(builder: EndpointBuilder, operations: Vec<Operation>) -> Endpoint {
let mut endpoint = builder.build();

Expand Down

0 comments on commit 46633ef

Please sign in to comment.