Giter VIP home page Giter VIP logo

Comments (18)

TimothyYe avatar TimothyYe commented on April 26, 2024

Agree with it.

from gin.

naoina avatar naoina commented on April 26, 2024

FYI, see https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Initialisms.

from gin.

pinscript avatar pinscript commented on April 26, 2024

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

from gin.

allochi avatar allochi commented on April 26, 2024

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.

from gin.

manucorporat avatar manucorporat commented on April 26, 2024

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.

from gin.

unknwon avatar unknwon commented on April 26, 2024

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

+1

from gin.

iswarezwp avatar iswarezwp commented on April 26, 2024

Capitalized is more readable.

from gin.

haoxins avatar haoxins commented on April 26, 2024

+1 for Get, Post, Put, etc

from gin.

julienschmidt avatar julienschmidt commented on April 26, 2024

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.

from gin.

1l0 avatar 1l0 commented on April 26, 2024

EITHER will be fine to me.

from gin.

jonathaningram avatar jonathaningram commented on April 26, 2024

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.

from gin.

julienschmidt avatar julienschmidt commented on April 26, 2024

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

from gin.

jonathaningram avatar jonathaningram commented on April 26, 2024

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

from gin.

manucorporat avatar manucorporat commented on April 26, 2024

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()?

from gin.

unknwon avatar unknwon commented on April 26, 2024

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

Definitely if you do so.

from gin.

allochi avatar allochi commented on April 26, 2024

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.

from gin.

manucorporat avatar manucorporat commented on April 26, 2024

hahaha brilliant fix

from gin.

unknwon avatar unknwon commented on April 26, 2024

Well done!

from gin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.