Giter VIP home page Giter VIP logo

http-status's Introduction

http-status

List of HTTP status codes and reasons.

Usage

var code:HttpStatusCode = OK;
var reason = new HttpStatusMessage(code);
// or use implicit cast
var reason:HttpStatusMessage = code;

Unofficial codes

HttpStatusCode contains the current official specifications for HTTP status code.

There exist other unofficial codes, that can be regrouped by categories (Microsoft, Nginx and so on). Overlap is very small right now but there are added in the httpstatus.unofficial package anyway.

Only the Microsoft.hx http status codes are implemented right now. Feel free to PR for others.

import httpstatus.HttpStatusCode;
import httpstatus.HttpStatusMessage;
import httpstatus.unofficial.Microsoft;

var code    : Microsoft         = SessionTimeout;   // 440
var code2   : HttpStatusCode    = SessionTimeout;   // 440

var reason  : HttpStatusMessage = SessionTimeout;   // "Client Session Expired Must Log In Again"
var reason2 : HttpStatusMessage = code;             // "Client Session Expired Must Log In Again"
// but:
var reason3 : HttpStatusMessage = code2;            // "Unknown Status". This is a limitation 

With tink

There are automatic #if tink_core fences in the code, so this does not require it.

Producing these error codes on a server using tink is straightforward. When getting a tink.core.Error on the client, one can use switch (e.code : HttpStatusCode). If your server chose to use some exotic status code such as 440 SessionTimeout (Microsoft), you can use something like:

switch (e.code : httpstatus.unofficial.Microsoft) {
    case SessionTimeout:
    case Forbidden:         // regular codes from HttpStatusCode are also available
}

http-status's People

Contributors

kevinresol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

http-status's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.