Skip to content

Instantly share code, notes, and snippets.

@Juoelenis
Last active November 19, 2024 17:47
Show Gist options
  • Save Juoelenis/770f621160a13c551abe34b62c94af44 to your computer and use it in GitHub Desktop.
Save Juoelenis/770f621160a13c551abe34b62c94af44 to your computer and use it in GitHub Desktop.
this is where i post cool code samples from HPP, feel free to copy paste from here!
@Juoelenis
Copy link
Author

code snippet for log4j and node.js
made in rust:
`// Log that the application has started
log::info!("Redirector service starting...");

// Define the redirect route
let redirect_route = warp::path("redirect")
    .and(warp::query::<std::collections::HashMap<String, String>>())
    .map(|query_params: std::collections::HashMap<String, String>| {
        if let Some(target) = query_params.get("url") {
            log::info!("Redirecting to: {}", target);
            warp::redirect::temporary(target.parse().unwrap_or_else(|_| {
                log::error!("Invalid URL: {}", target);
                warp::http::Uri::from_static("/error")
            }))` makes sure everything has started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment