variable mime
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
c112dd7407
commit
0d80322526
23
src/main.rs
23
src/main.rs
@ -12,24 +12,19 @@ mod snippet;
|
|||||||
|
|
||||||
use crate::pgp::KnownKeys;
|
use crate::pgp::KnownKeys;
|
||||||
use crate::snippet::*;
|
use crate::snippet::*;
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
|
||||||
use chacha_io::{ChaChaReader, ChaChaWriter};
|
|
||||||
use chrono::*;
|
|
||||||
use core::cell::RefCell;
|
|
||||||
use iron::method::Method;
|
use iron::method::Method;
|
||||||
use iron::modifiers::Redirect;
|
use iron::modifiers::Redirect;
|
||||||
use iron::prelude::*;
|
use iron::prelude::*;
|
||||||
use iron::url::Url;
|
use iron::url::Url;
|
||||||
use rand::Rng;
|
|
||||||
use sha2::{Digest, Sha256};
|
use iron::mime::Mime;
|
||||||
use std::borrow::BorrowMut;
|
use sha2::Digest;
|
||||||
use std::convert::TryInto;
|
|
||||||
use std::fs;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
@ -104,10 +99,12 @@ fn handle(req: &mut Request) -> IronResult<Response> {
|
|||||||
let mut parts = path.split(".");
|
let mut parts = path.split(".");
|
||||||
(
|
(
|
||||||
parts.next().unwrap().to_string(),
|
parts.next().unwrap().to_string(),
|
||||||
parts.next().flat_map(|format| format.parse::<Mime>().ok()),
|
Some(parts.collect::<Vec<_>>().join("/"))
|
||||||
|
.filter(|s| s.len() > 0)
|
||||||
|
.and_then(|format| format.parse::<Mime>().ok()),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let mime = mime.unwrap_or("application/text".parse().unwrap());
|
let mime = mime.unwrap_or("text/plain".parse().unwrap());
|
||||||
let att = storage.open(&id).map(|snip| snip.contents()).map(|res| {
|
let att = storage.open(&id).map(|snip| snip.contents()).map(|res| {
|
||||||
Response::with(
|
Response::with(
|
||||||
match res.map(|text| (iron::status::Ok, text)).map_err(|err| {
|
match res.map(|text| (iron::status::Ok, text)).map_err(|err| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user