Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Klugier is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: MemFn() only offers void return types
Next Topic: Incorrect SHA1 checksum for files 4GB+
Goto Forum:
  


Current Time: Sat Jun 07 10:23:35 CEST 2025

Total time taken to generate the page: 0.04404 seconds