CoreFunc HTTP
Utilities and tools to help build HTTP requests.
Please Note: This is not a production-ready package! Expect long stretches of zero updates—that does not mean that the module is outdated. This is "Don’t repeat yourself" collection. Yes, it's working fine, but it is not complete neither consistent. The files can move from folder to folder without warning. Everything is a "Work in Progress"!!!
Usage
CommonJS import.
const {
HTTP_HEADER,
STATUS_CODE_EMPTY, STATUS_CODE_TEXT,
httpResponseJson, httpStatusText,
} = require("@corefunc/http");
ECMAScript Module.
import {
HTTP_HEADER,
STATUS_CODE_EMPTY, STATUS_CODE_TEXT,
httpResponseJson, httpStatusText,
} from "@corefunc/http";
AMD, UMD, browser script tag.
<script src="https://unpkg.com/@corefunc/http"></script>
CDN (unpkg https://unpkg.com/)
<script src="https://unpkg.com/@corefunc/http" type="module"></script>
Deno (Pika https://pika.dev/)
import {
HTTP_HEADER,
STATUS_CODE_EMPTY, STATUS_CODE_TEXT,
httpResponseJson, httpStatusText,
} from "https://cdn.pika.dev/@corefunc/http";
Examples
httpResponseJson(200);
httpResponseJson("200");
httpResponseJson`200`;
httpResponseJson(403, "Not for you");
httpResponseJson`403 Not for you`;
httpResponseJson(500, { errorForDeveloper: "", errorForUser: "" });
API
- HTTP_HEADER
- HTTP_MEDIA_TYPE
- HTTP_METHOD
- STATUS_CODE_EMPTY
- STATUS_CODE_REDIRECT
- STATUS_CODE_RETRY
- STATUS_CODE_TAG
- STATUS_CODE_TEXT
- httpResponse()
- httpResponseHtml()
- httpResponseJson()
- httpResponseText()
- httpResponseXml()
- httpStatusCode()
- httpStatusText()
See also
My other projects