JASMY Will be Available on CoinTiger on 26 April.

We are excited to announce that JASMY will be available on CoinTiger. JASMY/USDT trading pair will be available at the same time. JasmyCoin is a data marketplace project where users are able to sell…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Using HTTP status codes in Deno

HTTP status codes are one of the most basic constants used in any web application. Official HTTP status codes range from 100–599. These status codes are useful in two scenarios:

In either of the cases, there is a need to read, write, or understand HTTP status codes. While the official HTTP status codes are fixed, it’s not elegant to directly use numbers like 206, 403, 412, 511, etc. These magic numbers could be readable for experts, but for most people, it’d require them to Google the code to understand the meaning.

Deno provides an elegant way to read, write, and understand HTTP status codes. All the official status codes are covered by Deno.

There are two ways to use the HTTP status codes in Deno.

The first way is to include the Status object from the HTTP status module. This status object contains key-value pairs where:

Here is the complete list of the user-friendly keys and numeric values present in the Status object:

Let’s go over some examples and see how the status codes would get used.

The first example is that sends status codes 200 and 400 from a simple web server:

If there are some parameters missing in the request, it sends Status.BadRequest (400). If everything is good, it sends Status.OK (200). The status text i.e. the description is sent automatically by Deno.

Add a comment

Related posts:

seharusnya aku harus seharus harusnya

Apanya arti hidup ini. harusnya aku hanya mendengarkan ceramah batin di televisi agar aku tak menanti-nanti sepi, namun itu yang aku dapat. Bila diri sendiri tak kau dengar lantas perkataan siapa…

Introducing ZetaChain Omnichain Smart Contracts

Omnichain Smart Contracts support on ZetaChain’s testnet. This enables a new paradigm for web3 dApp building, unlocking concepts such as Bitcoin Smart Contracts. Enter the app now to experience…

10 Ways to Get Out of the Frenzy

In this world of needing to strive, and to be accomplished, and be something, I often find myself in a kind of mental and emotional frenzy. This is a great way to feel disillusioned and get sick, if…