shelf_enforces_ssl 1.0.0 shelf_enforces_ssl: ^1.0.0 copied to clipboard
Enforces that users can only make API requests over HTTPS (SSL).
example/shelf_enforces_ssl_example.dart
// ignore_for_file: avoid_print
import 'package:shelf_enforces_ssl/shelf_enforces_ssl.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;
void main() async {
final handler = const Pipeline()
.addMiddleware(enforceSSL())
.addMiddleware(logRequests())
.addHandler(_echoRequest);
final server = await shelf_io.serve(handler, 'localhost', 8080);
print('Serving at https://${server.address.host}:${server.port}');
}
Response _echoRequest(Request request) =>
Response.ok('Request for "${request.url}"');