Skip to content

Instantly share code, notes, and snippets.

@benaryorg
Created January 1, 2016 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benaryorg/ec9548e04d70b34b2c49 to your computer and use it in GitHub Desktop.
Save benaryorg/ec9548e04d70b34b2c49 to your computer and use it in GitHub Desktop.
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
struct Context
{
root: String,
index: String,
}
fn get(uri: &str,context: &Arc<Context>)
{
let mut path = PathBuf::new();
if uri != "/"
{
path.push(&context.root);
path.push(&uri);
}
else
{
path.push(&context.index)
};
send(&path);
}
fn send(p: &Path)
{
println!("{:?}",p);
}
fn main()
{
let context = Arc::new
(
Context
{
root: "/home".to_string(),
index: "/home/index.html".to_string(),
}
);
get("3",&context.clone())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment