Home » U++ Library support » U++ Core » Core Http API change proposals - HttpStatus and HttpMethod as enum class
Re: Core Http API change proposals - HttpStatus and HttpMethod as enum class [message #50011 is a reply to message #50003] |
Sun, 17 June 2018 21:02   |
 |
Klugier
Messages: 1099 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello,
I agree with your, however I think we can still make it better for the final user. Instead of defining enum class we can define consts values. For example:
class HttpMethod {
public:
static const String Get = "GET";
static const String Head = "HEAD";
HttpMethod() = delete;
};
The same thing we can do with Http status code:
class HttpStatus {
public:
static const int Continue = 100;
...
static const int OK = 200;
String ToString(int status) {
// Can returned string basing on status code.
}
HttpStatus() = delete;
};
I do not like the current approach when you need to explicitly write String in your code. This is more risk prone for the final user, because he can make spelling mistake in the code. In my approach it is verified on compilation level.
My idea is basing on following go standard library implementation:
- https://golang.org/src/net/http/method.go
- https://golang.org/src/net/http/status.go
Sincerely,
Klugier
U++ - one framework to rule them all.
[Updated on: Sun, 17 June 2018 21:07] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Jun 08 01:06:14 CEST 2025
Total time taken to generate the page: 0.31188 seconds
|