Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http method name in uppercase is too ugly.. #9

Closed
insionng opened this issue Jul 1, 2014 · 18 comments
Closed

http method name in uppercase is too ugly.. #9

insionng opened this issue Jul 1, 2014 · 18 comments
Assignees

Comments

@insionng
Copy link

insionng commented Jul 1, 2014

So, hoping to use the first letter capitalized in such a way ..
Get Post Put etc.

@TimothyYe
Copy link

Agree with it.

@naoina
Copy link

naoina commented Jul 1, 2014

@pinscript
Copy link
Contributor

It's also consistent with the routing framework used (julienschmidt/httprouter).

@allochi
Copy link

allochi commented Jul 1, 2014

It's actually the way HTTP methods should be see
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9

Now, with the Initialisms rule from naoina's link, I recommend they stay.

@manucorporat
Copy link
Contributor

I also think that using capitalized GET and POST is a good way to understand that methods create a GET and POST route respectively, we are not getting a value or posting whatever.

In fact gin.Context has a method called Get(key), it's a helper to get a value from the hash map, if the key doesn't exist, it would panic.

@unknwon
Copy link

unknwon commented Jul 1, 2014

So, hoping to use the first letter capitalized in such a way ..
Get Post Put etc.

+1

@iswarezwp
Copy link

Capitalized is more readable.

@haoxins
Copy link

haoxins commented Jul 1, 2014

+1 for Get, Post, Put, etc

@julienschmidt
Copy link
Contributor

I also think that using capitalized GET and POST is a good way to understand that methods create a GET and POST route respectively, we are not getting a value or posting whatever.

This was exactly my intention and the reason why it is used this way in the HttpRouter package.

@1l0
Copy link

1l0 commented Jul 1, 2014

EITHER will be fine to me.

@jonathaningram
Copy link

I think that lowercase is better - all your routes will generally be defined together so it's obvious that it's not a "get something" method call. I think the only way to decide what option to use is to decide if you want to completely follow the "official" code style, which IMO is a good decision because following that guide means that this issue would never have come up in the first place :) that's just what I think anyway.

@julienschmidt
Copy link
Contributor

As noted above, this is not against the code guidelines.

@jonathaningram
Copy link

@julienschmidt ah you're right, apologies - in that case I say leave it as is because they do follow the guidelines.

@manucorporat
Copy link
Contributor

I understand that Get, Post, Put may look better for some people, but since it's already capitalized I do not think it's a good idea to change it. The document referred by @naoina is also a good source to leave it as is.

And, if we change POST() to Post(), should we also rename context.JSON() to context.Json()?

@unknwon
Copy link

unknwon commented Jul 2, 2014

And, if we change POST() to Post(), should we also rename context.JSON() to context.Json()?

Definitely if you do so.

@allochi
Copy link

allochi commented Jul 2, 2014

Just a simple silly comment, does this solve your problem? 😄

r := gin.Default()
var Get = r.GET
Get("/", home)

Not only it's a Get now, but it also doesn't have r. 😄 .

Again I recommend keeping them in caps as they are inline with their HTTP meaning.

@manucorporat
Copy link
Contributor

hahaha brilliant fix

@unknwon
Copy link

unknwon commented Jul 2, 2014

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests