3 ms·
I'd love to hear how folks are actually deploying Golang for web apis - using Gorilla, net/http, etc?
by count 12y ago
I'd love to hear how folks are actually deploying Golang for web apis - using Gorilla, net/http, etc?
- themartorana 12y agoWe're using either Gin[0] or pure net/http with Julian Schmidt's HttpRouter[1]. Even Gin lives on top of net/http, and most serious routers/frameworks do. [0] https://github.com/gin-gonic/gin https://github.com/gin-gonic/gin [1] https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter
- namidark 12y agoUpstart + net/http
- jaegerpicker 12y agoFirst one I deployed I used martini but now I'd just use the net/http lib and pull in a few gorilla libs as needed.
- steakejjs 12y agoNginx and net/http has worked wonderfully for me. Nothing fancy is necessary.
- stilldavid 12y agoLike the others, net/http with gorilla packages pulled in as needed. Nginx for static files and a reverse proxy for go. Upstart, and that's about it!
- neillyons 12y agoI have multiple Go apps on my Linode server. I use nginx as a reverse proxy. Each Go app listens on a different port. I use supervisor to start/stop my Go programs. I also use it for log rotate and to autostart my programs on a system reboot.
- buro9 12y agoI've created a simple solution for a few projects I'm working on, it's a kind of REST service wrapper. Basically, I have a "service" package that offers: * mux routing * Negroni for middleware (with stats and auth middlewares delivered out of the box) * a centralised logger * Rendering of things to JSON * An idea of controllers (a controller is a web handler for a given route, handling all verbs) * An idea of handlers on those controllers (per verb... you basically just load in your GET or POST handlers here) * HEAD and OPTIONS for free (including automatic Allow headers) * Error handling returns JSON throughout, including 404s, etc * Basic filling of structs with POST'd/PUT'd JSON The thing is fairly primitive, and it's Go idiomatic and so doesn't provide a context for the middleware and handlers, but it just allows one to rapidly say "this struct, to this controller, on this route" and the rest is for free. This is just a starting ground though, a test of an idea. If I can package this better and have it be a little less hacky in nature I'll look to open-sourcing it. Right now it's really just testing the idea of taking all of the cross-cutting concerns and common issues and solving them via this service package I've made, with the goal of just letting us get on with writing the business logic. I want to expand it... with better description of errors, standard schemas for arrays being returned, auto-documentation of the endpoints (perhaps Swagger, but it seems awfully monolithic in nature), etc.