Skip to main content
Module

x/oak/mod.ts>SendOptions

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Extremely Popular
Go to Latest
interface SendOptions
import { type SendOptions } from "https://deno.land/x/oak@v12.5.0/mod.ts";

Properties

optional
brotli: boolean

Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists. (defaults to true)

optional
contentTypes: Record<string, string>

A record of extensions and content types that should be used when determining the content of a file being served. By default, the media_type database is used to map an extension to the served content-type. The keys of the map are extensions, and values are the content types to use. The content type can be a partial content type, which will be resolved to a full content type header.

Any extensions matched will override the default behavior. Key should include the leading dot (e.g. .ext instead of just ext).

Example

app.use((ctx) => {
  return send(ctx, ctx.request.url.pathname, {
    contentTypes: {
      ".importmap": "application/importmap+json"
    },
    root: ".",
  })
});
optional
extensions: string[]

Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to undefined)

optional
format: boolean

If true, format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory and /directory/. (defaults to true)

optional
gzip: boolean

Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. (defaults to true).

optional
hidden: boolean

Allow transfer of hidden files. (defaults to false)

optional
immutable: boolean

Tell the browser the resource is immutable and can be cached indefinitely. (defaults to false)

optional
index: string

Name of the index file to serve automatically when visiting the root location. (defaults to none)

optional
maxage: number

Browser cache max-age in milliseconds. (defaults to 0)

optional
maxbuffer: number

A size in bytes where if the file is less than this size, the file will be read into memory by send instead of returning a file handle. Files less than the byte size will send an "strong" ETag header while those larger than the bytes size will only be able to send a "weak" ETag header (as they cannot hash the contents of the file). (defaults to 1MiB)

root: string

Root directory to restrict file access.