jaguar_static_file 0.5.5 copy "jaguar_static_file: ^0.5.5" to clipboard
jaguar_static_file: ^0.5.5 copied to clipboard

Dart 1 only

Static file handler for jaguar

jaguar_static_file #

Provides two ways to serve static files

  1. StaticFileHandler : RequestHandler based
  2. StaticFile : Interceptor based

StaticFileHandler #

StaticFileHandler is RequestHandler based. It can be directly added to Jaguar server using addApi method or included in an Api using IncludeApi annotation.

Usage #

Future main() async {
  final server = new Jaguar();
  server.addApi(
      new StaticFileHandler('/public/*', new Directory('./example/static/')));
  await server.serve();
}

StaticFile #

StaticFile is an interceptor that substituted JaguarFile in response with actual content of the file JaguarFile (JaguarFile) points to.

Usage #

@Api()
class MyApi extends _$MyApi {
  @Get(path: '/file')
  @WrapOne(#staticFile)
  JaguarFile getFile(Context ctx) =>
      new JaguarFile(Directory.current.path + "/static/file.css");

  @Get(path: '/static/:filename*')
  @WrapOne(#staticFile)
  JaguarFile getDir(Context ctx) => new JaguarFile(
      Directory.current.path + '/static/' + ctx.pathParams['filename']);

  StaticFile staticFile(Context ctx) => new StaticFile();
}
0
likes
5
pub points
0%
popularity

Publisher

unverified uploader

Static file handler for jaguar

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

jaguar

More

Packages that depend on jaguar_static_file