Skip to main content
Module

x/ghst/mod.ts>GhstApplication

A light-weight http framework built for Deno.
Latest
class GhstApplication
import { GhstApplication } from "https://deno.land/x/ghst@v1.1.4/mod.ts";

Constructors

new
GhstApplication(options?: MiddlewareOptions)

Properties

private
_middleware: MiddlewareFunc[]
private
_requests: Record<string, Req>
readonly
on404: (arg0: HTTPRequest, arg1: HTTPResponse) => void

How the application handles 404 requests.

Methods

listen(
port: number,
hostname?: string,
callback?: () => void,
)

Starts listening for requests.

onRequest(
path: string,
method: Methods,
callback: (arg0: HTTPRequest, arg1: HTTPResponse) => void,
)

Adds a request to your web app.

setStatic(path: string)

Sets the static directory to avoid content type errors.

Static Properties

ContentTypeHeaders: Record<string, string>

Content types for (some) file extentions.

Static Methods

deprecated
ContentType(contentType: string): MiddlewareFunc

Middleware for setting a default content type header on all requests. Not recommended with use of sendFile().

A function meant to mimic the behavior of the express helmet middleware.