On the server side you don't know the scheme used. It isn't part of the request as such. It has to be determined based on the properties of the port that got the request (if you are listening with TLS on a port, the request you got is definitely some flavour of https). If you have a reverse proxy, or load balancer in front of your app it maybe get passed the scheme in a header (x-forwarded-proto IIRC)
On Sun, 25 Nov 2018, 08:13 robert engels, <reng...@ix.netcom.com> wrote: > Technically, the Scheme is optional, but if your url has it, it should be > parsed into that field. > > > On Nov 25, 2018, at 1:19 AM, Anik Hasibul <anik3...@gmail.com> wrote: > > Thank you so much. I thought I did something wrong. But Now I am pretty > sure that it's a bug. > > Issue opened on GitHub! > > Here it is: https://github.com/golang/go/issues/28940 > > Hasibul Hasan (Anik) > > Mobile: +8801902566424 > Email : anikhasi...@outlook.com > Github: @AnikHasibul > Medium: @AnikHasibul > > ------------------------------ > *From:* Robert Engels <reng...@ix.netcom.com> > *Sent:* Sunday, November 25, 2018 10:20:46 AM > *To:* Anik Hasibul > *Cc:* golang-nuts > *Subject:* Re: [go-nuts] How to get request url scheme? > > That should be it... file a bug > > > On Nov 24, 2018, at 9:21 PM, Anik Hasibul <anik3...@gmail.com> wrote: > > > > Hi there! > > I am working on a web application. And I need to get the scheme of the > request url. > > I tried `req.URL.Scheme` it returned empty string. > > But my expectation was `http` or `https` > > > > Any idea to get that? > > > > -- > > You received this message because you are subscribed to the Google > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to golang-nuts+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.