These are chat archives for gin-gonic/gin

19th
Oct 2016
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:34
Anyone alive?
If yes, I have some questions
I think it's for sessions, is it not?
David Marchbanks
@ptdave20
Oct 19 2016 15:35
yes, I am alive
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:35
Also, I think it's possible to read the body directly from Gin... currently I do ```go
body := ioutil.ReadAll(ctx.Request.Body)
David Marchbanks
@ptdave20
Oct 19 2016 15:37
if you are using the gin session middlware, you can use their Default function to read the session data
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:37
hmm, then what does ctx.Get read from?
Is it some key-value storage ?
David Marchbanks
@ptdave20
Oct 19 2016 15:37
the context is just data between middleware
you can pass your database connections that way, but I honestly use MustGet rather than get
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:38
pass database connections from what to what?
What is Get/Set reading from ? Is it the URL query string or POSTed Form or some internal key-value database
David Marchbanks
@ptdave20
Oct 19 2016 15:40
So lets say one middleware starts your database connection, and uses the context.Set and then calls context.Next to go to the next middleware or the final route function. You can call the context.Get or MustGet to retrieve the information put in using the set
look at it as a share chunk of memory the connection uses from beginning to end
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:41
(and btw, I'm here to Gin because I just ditched Iris because of how kataras treated third-party contributors (me included))
well, so it's a internal key-value storage used by middlewares
David Marchbanks
@ptdave20
Oct 19 2016 15:41
I moved to gin this summer because of lack of updates in martini
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:41
nice, and is there any other way of directly reading from body in this?
and also again, can I run uWSGI with Go with Gin>
?*
David Marchbanks
@ptdave20
Oct 19 2016 15:42
are you reading json data?
not sure on the uWSGI, not familiar with that
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:43
no, I am reading MessagePack data
and sometimes (small) files directly posted without messing with the File-encoding that HTTP doe
s
All uWSGI needs to do is call uwsgi.Run() after you add all the routes to net/http, as Gin uses its own router, I can pass all routes to Gin using a single route as it was possible in gorrila/mux I think
The only difference is in calling uwsgi.Run() instead of initializing the Go HTTP server.
so it's easy as replacing the http.ListenAndServe with uwsgi.Run() and uWSGI handles the rest :smile:
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:48
(also, will Gin ever support fasthttp?)
David Marchbanks
@ptdave20
Oct 19 2016 15:48
that is the only way I am aware of getting the raw data. It has builtin tools though for any json data that I use a lot. But one thing you can do, some things have a decoder / encoder that you can pass a reader to. For example: json.NewDecoder(ctx.Request.Body). Then use any tools built in with that
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:48
Yeah, I think MessagePack library in Go does have that
David Marchbanks
@ptdave20
Oct 19 2016 15:49
I would use that, your code will be cleaner
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:51
nice, now what about the fasthttp and uWSGI GCCGO part
David Marchbanks
@ptdave20
Oct 19 2016 15:53
for fasthttp : gin-gonic/gin#498
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:53
I think I should not use uWSGI, it's near abandoned about it's GCCGO plugin
David Marchbanks
@ptdave20
Oct 19 2016 15:54
yeah, if it hasn't been updated in a year be very careful with it unless it's super simple
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:54
v2...
it's super simple because uWSGI does all the heavy lifting including routing
then it only exposes a takeover function that wraps uWSGI in a CGo compatible layer
then uWSGI does all the work
and... #498 is like... from April and now it's October
and also, uWSGI uses GCCGO which handles the Go part
Dean Karn
@joeybloggs
Oct 19 2016 15:57
fasthttp was attempted, but in order to impliment would require breaking changes which I believe the authors were not interested in.
besides it’s almost a complete culture shift std http vs fasthttp sticking with the fully supported std lib is probably best
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 15:59
well, as I see most of Gin works can be a wrapper of the fasthttp interface under the hood
David Marchbanks
@ptdave20
Oct 19 2016 15:59
I'm not very familiar with it, but for what I read on it, I don't know that it is worth it in gin. If you handle your routes well enough, it is really light weight
Dean Karn
@joeybloggs
Oct 19 2016 16:00
maybe but supporting 2 backends is also messy, and then there’s the user confusion; even echo is dropping fasthttp support as it was just too much
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:01
it was just too much? Iris just kind of broke everything to be performant, they went the fasthttp route.... But obviously Iris is a pos
David Marchbanks
@ptdave20
Oct 19 2016 16:02
never used Iris
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:02
aand don't, don't look at Iris, ever
fasthttp is a better HTTP server than net/http I think
Dean Karn
@joeybloggs
Oct 19 2016 16:03
don’t get me started on that guy I gave some friendly adive when his project first started and he escentially spit in my face and now….
define better fasthttp currently doesn;t support http2
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:03
that's what the benchmarks show, about 10x faster excepting the routes, where httprouter kicks in
yeah, Iris is a real piece of s
mm... that's a problem, many use HTTP/2
but does Gin use HTTP/2 anyway?
Dean Karn
@joeybloggs
Oct 19 2016 16:04
it’s all a matter of perspective and how you will use your project
Thomas Boerger
@tboerger
Oct 19 2016 16:04
the news of iris are awesome 8)
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:04
does Gin use HTTP/2 Server Pushes ?
Thomas Boerger
@tboerger
Oct 19 2016 16:04
and the lts release… with 5 commits…. roflmao
Dean Karn
@joeybloggs
Oct 19 2016 16:04
http2 is built into the std lib transparently so yet gin support http2
*yes
David Marchbanks
@ptdave20
Oct 19 2016 16:05
I use gin for a production environment from beginning to end. Let it handle the SSL and the routing. All my connections are completed within 100ms usually
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:05
lol, Iris' developer kataras is a premature OSS developer
who just removes git history and takes the patches out of PRs and merges it in master
Dean Karn
@joeybloggs
Oct 19 2016 16:06
anyways not getting into it, this is the Gin forum guys
Thomas Boerger
@tboerger
Oct 19 2016 16:06
a great oss developer :P
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:06
hmm, right, a really great developer
anyway, stop :P
@ptdave20 's functions are lightweight then
well, can I not just use nginx to reverse proxy fasthttp to provide HTTP/2 features?
David Marchbanks
@ptdave20
Oct 19 2016 16:07
i have some static file handlers, and then my api handlers with specific middleware for required areas
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:07
except the HTTP/2 server push, is it really needed in dynamic websites where you only write HTML and rest is done by NginX for static files
David Marchbanks
@ptdave20
Oct 19 2016 16:08
does http/2 with reverse proxy provide any benefits?
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:08
I think HTTP/2 server push is only meant to be used for static files
well, it should, nginx transforms HTTP/1.1 to HTTP/2 and because the HTTP/1.1 connections happen in localhost, there are no penalties that HTTP/1.1 produces (?)
David Marchbanks
@ptdave20
Oct 19 2016 16:10
hmmm, maybe if your reverse proxy was only doing routing to the api and your static files were handled directly from nginx file handlers
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:10
well, I will never trust any dynamic web framework to sanely serve my static assets
I just... saw... when I started, the Flask insanity
well, yes, nginx serves /static/* for me and reverse proxies the rest to my app server
so, if I do this and turn HTTP/2 on NginX, it will provide me the benefits of HTTP/2, so I may not need Gin's HTTP/2 support
David Marchbanks
@ptdave20
Oct 19 2016 16:13
some of the static handlers for gin are kinda messy. But I don't like dealing with Apache / Nginx
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:13
httpd is a mess
full of XML
httpd uses one thread per connection I guess
David Marchbanks
@ptdave20
Oct 19 2016 16:14
xml can die plz thankyou
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:14
mm... useless, nginx is way way better
and lighttpd is even better, but I don't feel like going the lighttpd way just yet
Dean Karn
@joeybloggs
Oct 19 2016 16:15
it should work for you, I try to keep it all in the go project so I can scale horizontally easier, but I am thinking from an enterprise application perspective
David Marchbanks
@ptdave20
Oct 19 2016 16:15
I have had issues with large files with Apache atleast and it giving up on the file. Really frustrating
file uploads that is
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:16
lol, quit using httpd
and use nginx or lighttpd
Apache is messy, it's reverse proxies just suck
David Marchbanks
@ptdave20
Oct 19 2016 16:17
also, caching. I purposely tell my api's to have no caching headers.
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:17
mmm, transparents, I use Varnish
the frontfacing user goes through Varnish then to NginX then to my beloved Gin appserver
David Marchbanks
@ptdave20
Oct 19 2016 16:22
Too much software imo, rather handle the traffic myself
I am honestly waiting for IncludeOS to mature
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:25
well, it uses alots of software but is performant and cool
not exactly 'cool' but it does what I want transparently without me fiddling with random configurations in random things I use
what is IncludeOS
and btw, why only C++ :worried: I want Go
David Marchbanks
@ptdave20
Oct 19 2016 16:26
I personally love C++, and Go
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:26
mmm, can't I just CGo include os ?
David Marchbanks
@ptdave20
Oct 19 2016 16:27
but the servers created are saying up to 1MB in size.
short of assets included in the images
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:28
C++ is insane, says one of the Go's creators, I agree, I also hate C++
use go-bindata?
David Marchbanks
@ptdave20
Oct 19 2016 16:29
I like compiled languages vs interpretted. I feel dirty with interpretted
so golang and c++ sit well with me
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:31
I just found Clive, a Go-powered Unikernel OS...
David Marchbanks
@ptdave20
Oct 19 2016 16:31
I'm rooting for these unikernels. I think it's the way to go
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:32
I can just pull Clive, add it to my main.go with Gin, vendor it all together, build and run on production KVM dedicated servers?
David Marchbanks
@ptdave20
Oct 19 2016 16:32
ideally
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:32
awesome idea
David Marchbanks
@ptdave20
Oct 19 2016 16:33
the low overhead plus total size of the image will allow things to get really cheap
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:35
so, currently unikernel enthusiast got to wait till a stable unikernel is available where I can include/import and compile and run!
David Marchbanks
@ptdave20
Oct 19 2016 16:36
yup. I've tested the c++ version, really neat results with minimal work. still very young
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:37
hmm, why doesn't one exist for Go
David Marchbanks
@ptdave20
Oct 19 2016 16:38
not sure, I only heard about IncludeOS from CppCon and a podcast
Mr. Zenified
@ZenifiedFromI2P
Oct 19 2016 16:42
Goalone seems interesting..
Currently for minimal apps, meh.... just install Alpine, run your app on startup with cronjob, that's pretty much it
Javier Provecho Fernandez
@javierprovecho
Oct 19 2016 19:39
Hi @ZenifiedFromI2P , welcome to "the gin forum" 😅.
Feel free to open pr, I just opened the gin org and we hope (definitely) to make the gin project move again.
Thomas Boerger
@tboerger
Oct 19 2016 22:08
We will move again with the new people power :)