SensitiveHeaderMiddleware
struct SensitiveHeaderMiddleware
Middleware for marking headers' values as sensitive information.
Sensitive data could represent passwords or other data that should not be stored on disk or in memory. By marking header values as sensitive, components using this crate can be instructed to treat them with special care for security reasons.
Example
nv
use std.net.http.server.{
middlewares.SensitiveHeaderMiddleware,
Router,
};
let app = Router.new().with(SensitiveHeaderMiddleware.new(["x-api-key1", "x-api-key2"]));
Fields
Implementions
Methods
new
pub fn new(headers: [string], applied_to: SensitiveHeaderAppliedTo = SensitiveHeaderAppliedTo.Both): SensitiveHeaderMiddleware
[src]
pub fn new(
headers: [string], applied_to: SensitiveHeaderAppliedTo = SensitiveHeaderAppliedTo.Both
): SensitiveHeaderMiddleware {
return SensitiveHeaderMiddleware { headers, applied_to };
}
Creates a new SensitiveHeaderMiddleware
middleware.
new
pub fn new(headers: [string], applied_to: SensitiveHeaderAppliedTo = SensitiveHeaderAppliedTo.Both): SensitiveHeaderMiddleware
[src]
pub fn new(
headers: [string], applied_to: SensitiveHeaderAppliedTo = SensitiveHeaderAppliedTo.Both
): SensitiveHeaderMiddleware {
return SensitiveHeaderMiddleware { headers, applied_to };
}
Creates a new SensitiveHeaderMiddleware
middleware.
Creates a new SensitiveHeaderMiddleware
middleware.
[src]
pub fn transform(self, handler: Handler): Handler {
return handler
.around(|handler, request| {
if (self.applied_to != SensitiveHeaderAppliedTo.ResponseOnly) {
set_sensitive(request.headers(), self.headers);
}
let response = try handler.handle(request);
if (self.applied_to != SensitiveHeaderAppliedTo.RequestOnly) {
set_sensitive(response.headers(), self.headers);
}
return response;
});
}
[src]
pub fn transform(self, handler: Handler): Handler {
return handler
.around(|handler, request| {
if (self.applied_to != SensitiveHeaderAppliedTo.ResponseOnly) {
set_sensitive(request.headers(), self.headers);
}
let response = try handler.handle(request);
if (self.applied_to != SensitiveHeaderAppliedTo.RequestOnly) {
set_sensitive(response.headers(), self.headers);
}
return response;
});
}