Why not use Goweb? #49

Closed
matryer opened this Issue Sep 4, 2013 · 14 comments

Comments

Projects
None yet
6 participants
@matryer
Member

matryer commented Sep 4, 2013

Please leave a comment and tell us:

  • Why you chose not to use Goweb
  • Did it lack something you needed?
  • Do you think the project would benefit from an additional capability?
@tgulacsi

This comment has been minimized.

Show comment
Hide comment
@tgulacsi

tgulacsi Sep 4, 2013

Unscalable codecs - see stretchr/codecs#21

tgulacsi commented Sep 4, 2013

Unscalable codecs - see stretchr/codecs#21

@matryer

This comment has been minimized.

Show comment
Hide comment
@matryer

matryer Sep 4, 2013

Member

Thanks for the feedback.

On 3 Sep 2013, at 20:10, Islan Dberry notifications@github.com wrote:

I did not use goweb because I thought it would take longer to learn and understand goweb than it would to just write some code.


Reply to this email directly or view it on GitHub.

Member

matryer commented Sep 4, 2013

Thanks for the feedback.

On 3 Sep 2013, at 20:10, Islan Dberry notifications@github.com wrote:

I did not use goweb because I thought it would take longer to learn and understand goweb than it would to just write some code.


Reply to this email directly or view it on GitHub.

@oleksandr

This comment has been minimized.

Show comment
Hide comment
@oleksandr

oleksandr Sep 4, 2013

We tried to use net/http directly but ended up thinking again on generalizing response functions (read "controllers" used the same in different places), mapping requests and parameters to functions and keeping them the right RESTful way. It's an overhead from a project to project (not talking about small projects to roll out quicklt a bunch of resources). With Goweb we had to focus only on the following:

  • configuration (solved using custom yml/ini files)
  • dealing with database (we use goose for migrations there had to fork it to avoid hardcoded location of files/confs)
  • dev/live environments (used python's experience and relied on Buildout/Supervisord to create reproducable dev/live environments with single processes management tool)

We tried to use net/http directly but ended up thinking again on generalizing response functions (read "controllers" used the same in different places), mapping requests and parameters to functions and keeping them the right RESTful way. It's an overhead from a project to project (not talking about small projects to roll out quicklt a bunch of resources). With Goweb we had to focus only on the following:

  • configuration (solved using custom yml/ini files)
  • dealing with database (we use goose for migrations there had to fork it to avoid hardcoded location of files/confs)
  • dev/live environments (used python's experience and relied on Buildout/Supervisord to create reproducable dev/live environments with single processes management tool)
@oleksandr

This comment has been minimized.

Show comment
Hide comment
@oleksandr

oleksandr Sep 4, 2013

Such a relief :-) Even though Goweb put some constraints they are hackable. We didn't wont to end with Gorilla-based mambo-jumbo in Go ;-)

Such a relief :-) Even though Goweb put some constraints they are hackable. We didn't wont to end with Gorilla-based mambo-jumbo in Go ;-)

@an2deg

This comment has been minimized.

Show comment
Hide comment
@an2deg

an2deg Sep 4, 2013

I don't like a way how Goweb works with variables in mapping paths. It uses ugly github.com/stretchr/stew/objects (compare it with github.com/bitly/go-simplejson)
All Get* methods except GetString() return interface{} and I have to manually convert each value into proper type.
go-simplejson works in different way: Get() method returns Json object which has Int(), String(), Array() and e.t.c. methods. For example: js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()

an2deg commented Sep 4, 2013

I don't like a way how Goweb works with variables in mapping paths. It uses ugly github.com/stretchr/stew/objects (compare it with github.com/bitly/go-simplejson)
All Get* methods except GetString() return interface{} and I have to manually convert each value into proper type.
go-simplejson works in different way: Get() method returns Json object which has Int(), String(), Array() and e.t.c. methods. For example: js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()

@matryer

This comment has been minimized.

Show comment
Hide comment
@matryer

matryer Sep 17, 2013

Member

@an2deg we agree actually - so have tweaked the way Goweb deals with data by introducing the Objx package.

Member

matryer commented Sep 17, 2013

@an2deg we agree actually - so have tweaked the way Goweb deals with data by introducing the Objx package.

@an2deg

This comment has been minimized.

Show comment
Hide comment

an2deg commented Sep 18, 2013

@matryer Great!

@lukescott

This comment has been minimized.

Show comment
Hide comment
@lukescott

lukescott Oct 16, 2013

As a new user to goweb, these were my initial thoughts, right or wrong:

  • Several external dependencies. Why stewstrings.MergeStrings("foo", "bar") and not "foo" + "bar"?
  • Why Map(...anything...)? It's cool, but it's doesn't self document very well. Magical functions never do. Version 1 had more specific mapping functions. Why the change?
  • Returning an error from a controller function, such as Before, returns an html page instead of a json object. Some pages need an error html page, others need a json object. For example, I have /api/* for my API, but /* is for the website.
  • Default error handler advertises goweb. Pages like this should never say what is being used nor a version number.
  • How do I add /invoices/[id]/pay and have my controllers Before/After methods work?
  • [id] and {id} seem to be the same thing, at least in the context of /invoices/{id}/pay. /invoices//pay doesn't cause any errors when using {id}, so {id} seems to be optional as well. Still am not sure what the difference is.

As a new user to goweb, these were my initial thoughts, right or wrong:

  • Several external dependencies. Why stewstrings.MergeStrings("foo", "bar") and not "foo" + "bar"?
  • Why Map(...anything...)? It's cool, but it's doesn't self document very well. Magical functions never do. Version 1 had more specific mapping functions. Why the change?
  • Returning an error from a controller function, such as Before, returns an html page instead of a json object. Some pages need an error html page, others need a json object. For example, I have /api/* for my API, but /* is for the website.
  • Default error handler advertises goweb. Pages like this should never say what is being used nor a version number.
  • How do I add /invoices/[id]/pay and have my controllers Before/After methods work?
  • [id] and {id} seem to be the same thing, at least in the context of /invoices/{id}/pay. /invoices//pay doesn't cause any errors when using {id}, so {id} seems to be optional as well. Still am not sure what the difference is.
@jaredbischof

This comment has been minimized.

Show comment
Hide comment
@jaredbischof

jaredbischof Nov 18, 2013

I would like to use Goweb to run a server application on port 80 as a non-root user. Is this possible with Goweb 2? Currently I'm using Goweb version 1 and I found that if I use setgid and setuid after starting a server as root with Goweb the new threads that Goweb serves are still owned by root. This leads me to believe if did setgid and setuid inside Goweb that I could fix this, but I was wondering if this could be handled more gracefully with Goweb 2.

I would like to use Goweb to run a server application on port 80 as a non-root user. Is this possible with Goweb 2? Currently I'm using Goweb version 1 and I found that if I use setgid and setuid after starting a server as root with Goweb the new threads that Goweb serves are still owned by root. This leads me to believe if did setgid and setuid inside Goweb that I could fix this, but I was wondering if this could be handled more gracefully with Goweb 2.

@lukescott

This comment has been minimized.

Show comment
Hide comment
@lukescott

lukescott Nov 19, 2013

@jaredbischof You can do this without root using setcap. setcap 'cap_net_bind_service=+ep' /path/to/program

@jaredbischof You can do this without root using setcap. setcap 'cap_net_bind_service=+ep' /path/to/program

@jaredbischof

This comment has been minimized.

Show comment
Hide comment
@jaredbischof

jaredbischof Nov 19, 2013

That's actually precisely what I'm doing right now. :) I was just curious if there was a way to handle this inside golang for all threads.

That's actually precisely what I'm doing right now. :) I was just curious if there was a way to handle this inside golang for all threads.

@lukescott

This comment has been minimized.

Show comment
Hide comment
@lukescott

lukescott Nov 19, 2013

@jaredbischof Currently, not easily. That's a Go limitation though. It's difficult to ensure every thread does setuid/setgid (https://code.google.com/p/go/issues/detail?id=1435). setcap is actually safer because binding to port <1024 is all the program can do. privbind is another option.

@jaredbischof Currently, not easily. That's a Go limitation though. It's difficult to ensure every thread does setuid/setgid (https://code.google.com/p/go/issues/detail?id=1435). setcap is actually safer because binding to port <1024 is all the program can do. privbind is another option.

@jaredbischof

This comment has been minimized.

Show comment
Hide comment
@jaredbischof

jaredbischof Nov 20, 2013

Yeah, I saw that issue. Noticed it was pretty old, so I thought it might
have been fixed. But, thanks for confirming I'm taking the correct
approach!

On Tue, Nov 19, 2013 at 1:45 PM, Luke Scott notifications@github.comwrote:

@jaredbischof https://github.com/jaredbischof Currently, not easily.
That's a Go limitation though. It's difficult to ensure every thread does
setuid/setgid (https://code.google.com/p/go/issues/detail?id=1435).
setcap is actually safer because binding to port <1024 is all the program
can do. privbind is another option.


Reply to this email directly or view it on GitHubhttps://github.com/stretchr/goweb/issues/49#issuecomment-28825776
.

Yeah, I saw that issue. Noticed it was pretty old, so I thought it might
have been fixed. But, thanks for confirming I'm taking the correct
approach!

On Tue, Nov 19, 2013 at 1:45 PM, Luke Scott notifications@github.comwrote:

@jaredbischof https://github.com/jaredbischof Currently, not easily.
That's a Go limitation though. It's difficult to ensure every thread does
setuid/setgid (https://code.google.com/p/go/issues/detail?id=1435).
setcap is actually safer because binding to port <1024 is all the program
can do. privbind is another option.


Reply to this email directly or view it on GitHubhttps://github.com/stretchr/goweb/issues/49#issuecomment-28825776
.

@oleksandr

This comment has been minimized.

Show comment
Hide comment

@matryer matryer closed this Dec 17, 2013

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