Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinresol/http-status
List of HTTP status codes and reasons
https://github.com/kevinresol/http-status
haxe http http-status-code
Last synced: 29 days ago
JSON representation
List of HTTP status codes and reasons
- Host: GitHub
- URL: https://github.com/kevinresol/http-status
- Owner: kevinresol
- License: mit
- Created: 2016-05-25T06:55:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-26T05:34:21.000Z (over 4 years ago)
- Last Synced: 2024-10-19T02:04:37.130Z (3 months ago)
- Topics: haxe, http, http-status-code
- Language: Haxe
- Homepage:
- Size: 20.5 KB
- Stars: 12
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# http-status
List of HTTP status codes and reasons.
## Usage
```haxe
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.```haxe
import httpstatus.HttpStatusCode;
import httpstatus.HttpStatusMessage;
import httpstatus.unofficial.Microsoft;var code : Microsoft = SessionTimeout; // 440
var code2 : HttpStatusCode = SessionTimeout; // 440var 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](https://github.com/haxetink/tink_core) 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:```haxe
switch (e.code : httpstatus.unofficial.Microsoft) {
case SessionTimeout:
case Forbidden: // regular codes from HttpStatusCode are also available
}
```