Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpassos committed Jun 14, 2024
1 parent ad79fd4 commit fbd5279
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkgs/shelf_static/lib/src/static_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ final _defaultMimeTypeResolver = MimeTypeResolver();
///
/// The [Response.context] will be populated with "shelf_static:file" or
/// "shelf_static:file_not_found" with the resolved [File] for the [Response].
/// If the file is considered not found because it is outside of the
/// [fileSystemPath] and [serveFilesOutsidePath] is false, then neither key
/// will be included in the context.
/// If the path resolves to a [Directory], it will populate
/// "shelf_static:directory". If the path is considered not found because it is
/// outside of the [fileSystemPath] and [serveFilesOutsidePath] is false,
/// then none of the keys will be included in the context.
Handler createStaticHandler(String fileSystemPath,
{bool serveFilesOutsidePath = false,
String? defaultDocument,
Expand Down Expand Up @@ -176,6 +177,12 @@ File? _tryDefaultFile(String dirPath, String? defaultFile) {
/// This uses the given [contentType] for the Content-Type header. It defaults
/// to looking up a content type based on [path]'s file extension, and failing
/// that doesn't sent a [contentType] header at all.
///
/// The [Response.context] will be populated with "shelf_static:file" or
/// "shelf_static:file_not_found" with the resolved [File] for the [Response].
/// If the path is considered not found because it is
/// outside of the [fileSystemPath] and [serveFilesOutsidePath] is false,
/// then neither key will be included in the context.
Handler createFileHandler(String path, {String? url, String? contentType}) {
final file = File(path);
if (!file.existsSync()) {
Expand Down

0 comments on commit fbd5279

Please sign in to comment.