mirror of
https://github.com/felixblaschke/shelf_plus.git
synced 2025-08-03 17:43:18 +08:00
21 lines
460 B
Dart
21 lines
460 B
Dart
import 'dart:io';
|
|
|
|
import 'package:shelf_plus/shelf_plus.dart';
|
|
|
|
void main() => shelfRun(init);
|
|
|
|
dynamic pdfService;
|
|
|
|
Handler init() {
|
|
var app = Router().plus;
|
|
// #begin
|
|
app.get('/wallpaper/download', () => File('image.jpg'), use: download());
|
|
|
|
app.get('/invoice/<id>', (Request request, String id) {
|
|
File document = pdfService.generateInvoice(id);
|
|
return download(filename: 'invoice_$id.pdf') >> document;
|
|
});
|
|
// #end
|
|
return app.call;
|
|
}
|