Comments (18)
Agree with it.
from gin.
FYI, see https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Initialisms.
from gin.
It's also consistent with the routing framework used (julienschmidt/httprouter).
from gin.
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.
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.
So, hoping to use the first letter capitalized in such a way ..
Get Post Put etc.
+1
from gin.
Capitalized is more readable.
from gin.
+1 for Get
, Post
, Put
, etc
from gin.
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.
EITHER will be fine to me.
from gin.
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.
As noted above, this is not against the code guidelines.
from gin.
@julienschmidt ah you're right, apologies - in that case I say leave it as is because they do follow the guidelines.
from gin.
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.
And, if we change POST() to Post(), should we also rename context.JSON() to context.Json()?
Definitely if you do so.
from gin.
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.
hahaha brilliant fix
from gin.
Well done!
from gin.
Related Issues (20)
- Can't get status as expected from context.Status() HOT 1
- Gin Context implementation breaks context.Context contract HOT 4
- [Suggestions] Introducing an AI-powered robot to assist with daily issue and pull request (PR) tasks.
- Need c.JSON() response like behaviour for c.SSEvent() response for supporting first party clients like OpenAI SDK HOT 2
- custom time.Time type can not use bindQuery get a value. HOT 3
- configure server parameters HOT 1
- The binding:"required" tag does not seem to work for struct types HOT 3
- Is there a way to preserve order in JSON on response? HOT 1
- redirect is not success HOT 1
- I want to use shouldmindbodywith first and then use formafile, but it doesn't work right now HOT 3
- Extend the routing tree entry
- Transparent decompression for gzip, deflate, etc? HOT 1
- Custom time.Time type can not use bindQuery get a value 2 HOT 2
- http: response.Write on hijacked connection from github.com/gin-gonic/gin.(*responseWriter).Write (response_writer.go:83) HOT 1
- Suggestion: Move Print Debug to Run() functions? HOT 7
- AbortWithStatusJSON doesn't abort context HOT 2
- I translated `tree.go` into java
- GetUint and GetUint64 wrong return HOT 1
- Multipart form-data request with empty key for single file upload
- gin with golang 1.21, 1.22 DATA RACE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gin.