gottp icon indicating copy to clipboard operation
gottp copied to clipboard

Idiomatic go

Open alaypatel07 opened this issue 10 years ago • 2 comments
trafficstars

Refactored some code that looked pythonic with self as receivers. Added Comments for most Part of the code.

Comment worth reading in urls_handler.go :

// Get implements the method for UrlHandler. // It would be an advantage to have methods // implemented on urls in the response.

alaypatel07 avatar Oct 31 '15 17:10 alaypatel07

Fair point. Do you have anything in mind on how the response, for methods implemented on urls, should look like?

meson10 avatar Oct 31 '15 17:10 meson10

Yes. Infact i have a couple of points to be considered which are as follows.

  1. The current response looks like this Response :- {"data":{"RegisterUser":"/api/user","async_pipe":"^/async_pipe/?$","pipe":"^/pipe/?$","urls":"^/urls/?$"},"message":"","status":200}

I have only implemented POST method on the "RegisterUser" endpoint. It would be better if the response looked somewhat like this:-

Expected Response :- {"data":{"RegisterUser":{"Url":"/api/user", "Methods": ["POST"]}}, "message": "", "status": 200}

  1. However, the method OPTIONS is used exactly for that, i.e. knowing what methods are available for which particular endpoint. Hence the GlobalHandler should distinguish between request of OPTIONS method and set "Allow" header.

Please refer to the snippet I am sharing. screenshot from 2015-10-31 23 43 10

http://www.tutorialspoint.com/http/http_methods.htm

I am wanted to implement both the points today in my branch but i am confused on how to go about it. It will take time but i am hopeful, i will be able to complete it in a week or so.

Meanwhile do share your views on the same.

PS :- I have no idea on the Travis CI build error, I am sorry if your code broke

alaypatel07 avatar Oct 31 '15 18:10 alaypatel07