shelf_helmet 2.3.0 shelf_helmet: ^2.3.0 copied to clipboard
A port of the NodeJS helmet package to Dart. Helmet helps you secure your Dart Shelf/Frog apps by setting various HTTP headers.
Example #
Quick start #
First, run dart pub add shelf_helmet
for your app. Then:
As shelf middleware #
import 'package:shelf_helmet/shelf_helmet.dart';
var handler = const Pipeline()
.addMiddleware(helmet())
.addMiddleware(logRequests())
.addHandler(_echoRequest);
As dart_frog middleware #
import 'package:shelf_helmet/shelf_helmet.dart';
Handler middleware(Handler handler) {
return handler.use(
fromShelfMiddleware(helmet()),
);
}
As pharaoh middleware #
import 'package:shelf_helmet/shelf_helmet.dart';
app.use(useShelfMiddleware(helmet()));
You can find more specific examples in the readme.