Module

x/oak/etag.ts>calculate

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Very Popular
Go to Latest
function calculate
import { calculate } from "https://dotland.deno.dev/x/oak@v12.2.0/etag.ts";

Calculate an ETag for an entity. When the entity is a specific set of data it will be fingerprinted as a "strong" tag, otherwise if it is just file information, it will be calculated as a weak tag.

import { calculate } from "https://deno.land/std@$STD_VERSION/http/etag.ts";
import { assert } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts"

const body = "hello deno!";

const etag = await calculate(body);
assert(etag);

const res = new Response(body, { headers: { etag } });

Parameters

entity: Entity
optional
options: ETagOptions = [UNSUPPORTED]

Returns

Promise<string | undefined>
import calculate
import { calculate } from "https://dotland.deno.dev/x/oak@v12.2.0/etag.ts";