5 ms·
Does anyone have experience with Go as REST application server? I'm in prototyping phase (in Python) of something that is basically going to be a big REST API
by keypusher 13y ago
Does anyone have experience with Go as REST application server? I'm in prototyping phase (in Python) of something that is basically going to be a big REST API frontend with a lot of application logic and a db backend. I'm worried about scale as if this thing is going to take off it needs to scale big and support tens of thousands (or more) of requests a second. From the article it sounds like Go would be a great choice, I found the "gorest" framework and it looks decent, but I'm wondering if anyone has experience in this area? Specifically the DB interfacing, JSON marshalling, and writing lots of classes with complex application logic parts.
- danenania 13y agoI just put a small go learning project up on github. https://github.com/danenania/go-promocodes https://github.com/danenania/go-promocodes It's a tiny rest api for generating promo codes to bypass in app purchase locks in an ios app. It uses gorilla/mux[1] for routing, mongodb with mgo[2], and is heroku-ready[3]. One file and 129 lines all told. Perhaps it can help. 1: http://www.gorillatoolkit.org/pkg/mux http://www.gorillatoolkit.org/pkg/mux 2: http://labix.org/mgo http://labix.org/mgo 3: http://mmcgrana.github.io/2012/09/getting-started-with-go-on-heroku.html http://mmcgrana.github.io/2012/09/getting-started-with-go-on...
- dmishe 13y agoAdding to that, I have a large django project and I would love to use go for api, but how to deal with all the model code written in python?
- TheBiv 13y ago"I'm worried about scale as if this thing is going to take off it needs to scale big..." Please don't say this. If you are being paid by someone else, please check with them to ensure what their priorities are when things "scale big" bc often times you can bide yourself time if you have their requirements met while you scramble to make everything perfect on the backend. If you are not being paid by someone else or this is a side project, then please do not try and solve this question now. Answers to questions of "scale" are so broad that you will drive yourself mad trying to find the "perfect" tool, when one doesn't exist. You don't scale a language or a framework, you scale application logic. Scaling to millions of requests is the best possible problem to have, but put yourself in a position to have that problem! And asking basic questions of how to build something that can handle some amount of load in a language that you are not familiar with will FAR outweigh the perceived benefits of choosing that language/framework!
- keypusher 13y agoThanks for the advice, I am doing this for myself though, and what you are saying is why I started prototyping in Python.
- melvinmt 13y agoI had the same questions, so I went ahead and prototyped a tiny API in Go: https://github.com/melvinmt/translation.io https://github.com/melvinmt/translation.io Building an API in Go feels -very- robust because of the strong typing and the strict compiler. After a while you'll discover the strength of interfaces and be pleasantly surprised. Combined with the performance boost, I can't think of a better language to write an API in.
- agentS 13y agoFYI, you should replace DocsHandler with net/http's FileServer. Reasons: 1) the implementation is not vulnerable to path traversal attacks (i.e. if url.Path == "/../../../../../etc/passwd"). 2) It automatically handles index.html 3) It uses "/etc/mime.types" and other system files to automatically set mime types 4) It streams the file back instead of reading it all into memory.
- melvinmt 13y agoThanks! Didn't know about Fileserver. I'll look into it.
- jbarham 13y ago> Does anyone have experience with Go as REST application server? I'm developing my new startup (http://www.TurboHDR.com http://www.TurboHDR.com) in Go on App Engine and it's a very nice development environment. As part of the process I recently developed a WebDAV package (which I'll open source soon) and it was quite straightforward thanks to Go's great XML package (http://golang.org/pkg/encoding/xml/ http://golang.org/pkg/encoding/xml/) which automatically unmarshals XML into regular (possibly annotated) Go structures. The JSON package (http://golang.org/pkg/encoding/json/ http://golang.org/pkg/encoding/json/) can do the same. It's the most painless experience dealing with XML I've ever had. As another example, here's a simple (and admittedly, pretty frivolous) web server I wrote in Go to generate random passwords: https://github.com/jbarham/random-password-please https://github.com/jbarham/random-password-please.
- dualogy 13y ago> a WebDAV package (which I'll open source soon) Please do! Sooner rather than later -- no need for perfection ;)
- snaky 13y agoTry OpenResty - nginx + ngx_postgres/ngx_drizzle/ngx_hiredis/etc. for DB interfacing + ngx_rds_json for JSON marshalling + ngx_lua for complex application logic parts
- coocood 13y agoTake a look at https://github.com/coocood/jas https://github.com/coocood/jas I'm using it to build my web application.
- sauerbraten 13y agoShameless plug: I wrote a package that exposes a CRUD JSON API on top of a backend interface ("Storage") which you implement yourself; so if your API fits the CRUD principle it could be worth to look at: https://github.com/sauerbraten/crudapi https://github.com/sauerbraten/crudapi You could also use it to implement CRUD parts of your API and define your own handlers for more complex API parts.