darto_static 1.0.0 copy "darto_static: ^1.0.0" to clipboard
darto_static: ^1.0.0 copied to clipboard

Static file serving middleware for Darto.

darto_static #

Static file serving middleware for Darto.


Install #

dependencies:
  darto: ^1.0.0
  darto_static: ^1.0.0

Usage #

import 'package:darto/darto.dart';
import 'package:darto_static/darto_static.dart';

void main() async {
  final app = Darto();

  // Serve files from ./public at /public/*
  app.mount('/public/*', serveStatic('public'));

  await app.listen(3000);
}

Custom URL prefix #

Use the optional urlPrefix parameter when the mount path differs from the directory name:

// Files in ./dist served at /assets/*
app.mount('/assets/*', serveStatic('dist', urlPrefix: '/assets'));

Notes #

  • Path traversal protection built-in — requests cannot escape the served directory.
  • MIME types detected automatically via the mime package.
  • Falls through to next() when the requested file is not found, so other routes still match.

See also #

1
likes
130
points
72
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Static file serving middleware for Darto.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, darto, mime, path

More

Packages that depend on darto_static