Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
/ dia_static Public archive

The middleware for Dia http server, for serving static files

License

Notifications You must be signed in to change notification settings

unger1984/dia_static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED! Move to MONOREPO https://github.com/unger1984/dia

Pub Package

The middleware for Dia for serving static files.

Install:

Add to pubspec.yaml in dependencies section this:

    dia_static: ^0.1.1

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.

About

The middleware for Dia http server, for serving static files

Resources

License

Stars

Watchers

Forks