Pub Package

The middleware for Dia for serving static files.

Install:

Add to pubspec.yaml in dependencies section this:

    dia_static: ^0.1.2

Then run pub get

Usage:

A simple usage example:

import 'package:dia/dia.dart';
import 'package:dia_static/dia_static.dart';

void main() {
  final app = App();

  /// Serve files from example folder
  app.use(serve('./example'));

  app.use((ctx, next) async {
    ctx.body ??= 'error';
  });

  /// Start server listen on localhost:8080
  app
      .listen('localhost', 8080)
      .then((info) => print('Server started on http://localhost:8080'));
}

Params:

  • root - path to webserver root directory
  • prefix - url mast start with prefix value, optional.
  • index - default index file for serving if uri end with /. Default: null

Use with:

  • dia - A simple dart http server in Koa2 style.
  • dia_router - Middleware like as koa_router.
  • dia_body - Package with the middleware for parse request body.
  • dia_cors - Package for CORS middleware.

Features and bugs:

I will be glad for any help and feedback! Please file feature requests and bugs at the issue tracker.

Libraries

dia_static
Middleware for Dia that allows you to serving static files