ptth/crates/ptth_core/src/lib.rs

24 lines
643 B
Rust
Raw Normal View History

2020-11-27 00:03:11 +00:00
pub mod graceful_shutdown;
pub mod http_serde;
pub mod prelude;
2020-11-27 00:20:18 +00:00
// It's easier if the server can stream its response body
// back to the relay un-changed inside its request body
// So we wrap the server's actual response head
// (status code, headers, etc.) in this one header field.
pub const PTTH_MAGIC_HEADER: &str = "X-PTTH-2LJYXWC4";
2020-11-27 00:03:11 +00:00
// The arguments are in order so they are in order overall:
// e.g. prefix_match ("/prefix", "/prefix/middle/suffix") -> "/middle/suffix"
pub fn prefix_match <'a> (prefix: &str, hay: &'a str) -> Option <&'a str>
{
if hay.starts_with (prefix) {
Some (&hay [prefix.len ()..])
}
else {
None
}
}