gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
https://gin-gonic.com/
MIT License
78.12k stars 7.98k forks source link

SSL Support #227

Closed SedueRey closed 9 years ago

SedueRey commented 9 years ago

Hello,

I'm planning to use gin to get an RESTFull API but I don't see how shoud I use Gin to listen HTTPS connections. Is there any tutorial or video or contrib I could see?

Thanks,

matejkramny commented 9 years ago

I suggest you get nginx to listen to https and proxy the request to gin.

Matej Kramny

On Monday, 23 February 2015 at 09:47, Eduardo Rey Jara wrote:

Hello, I'm planning to use gin to get an RESTFull API but I don't see how shoud I use Gin to listen HTTPS connections. Is there any tutorial or video or contrib I could see? Thanks,

— Reply to this email directly or view it on GitHub (https://github.com/gin-gonic/gin/issues/227).

SedueRey commented 9 years ago

Cool! Same code for both listeners... I'll try. Thanks!

gladkikhartem commented 8 years ago

Nginx is preffered for SSL termination, because it's about 3 times faster in terms of handshaking. And Nginx better handles slow clients. However it's not an option for some situations. For example portable apps or similar.

Here's how to do out-of-the box SSL with gin:

import  "net/http"

err := http.ListenAndServeTLS(address, SSLCert, SSLPrivKey, ginRouter)
jiguangsdf commented 5 years ago

Nginx is preffered for SSL termination, because it's about 3 times faster in terms of handshaking. And Nginx better handles slow clients. However it's not an option for some situations. For example portable apps or similar.

Here's how to do out-of-the box SSL with gin:

import  "net/http"

err := http.ListenAndServeTLS(address, SSLCert, SSLPrivKey, ginRouter)

good

thinkerou commented 5 years ago

@jiguangin you can use RunTLS(address, SSLCert, SSLPrivKey)