question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide Response Code Enums

See original GitHub issue

What kind of issue is this?

  • Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.

I believe this library will benefit from having the Response object return an Enum on its method code(), like many other HTTP libraries and Frameworks do., so instead of:

if (response.code() == 200) { 
    // print "OK".
} else if (response.code() == 403) {
    // print "Forbbiden"
}

In which we have to memorize all the HTTP codes, and maybe mix some, we can have:

if (response.code() == HttpStatus.OK_200) { 
    // print "OK".
} else if (response.code() == HttpStatus.Forbidden_403) {
    // print "Forbbiden"
}

I think this will help the users to code quicker with the library (autocomplete can help with Enums) and beginners on REST and HTTP codes will be less prone to errors and mixing up what code does what.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

30reactions
swankjessecommented, Feb 7, 2018
2reactions
feinsteincommented, Feb 6, 2018

I think the code becomes more readable, maybe you guys deal with HTTP codes for a long time and don’t see the difference, but for beginners all those numbers on the middle of the logic can get a bit hard to read smoothly.

Just my $0.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does Java have a complete enum for HTTP response codes?
I'm debugging some Java code that uses javax.ws.rs.core.Response.Status . It works, but it only defines about half of the valid HTTP response ...
Read more >
Response.Status (Java(TM) EE 7 Specification APIs)
An enumeration representing the class of status code. Enum Constant Summary. Enum Constants. Enum Constant and Description.
Read more >
HttpStatusCode Enum (System.Net) - Microsoft Learn
Equivalent to HTTP status 200. OK indicates that the request succeeded and that the requested information is in the response. This is the...
Read more >
status-code-enum - npm
HTTP status codes as a TypeScript enum.. Latest version: 1.0.0, last published: 4 years ago. Start using status-code-enum in your project by ...
Read more >
HTTP Status Codes Java - Medium
Anytime an HTTP response is transmitted, a status code is included in the response. HTTP status codes are used to determine if the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found