Hi
I build gin & use curl to request api
use "github.com/happierall/l" to make the log pretty
use l.Log(c.Request.URL) and the log are below
c is
c *gin.Context
URL: &url.URL{
Scheme: "",
Opaque: "",
User: (*url.Userinfo)(nil),
Host: "",
Path: "/v1/playback/demo/videmo/id123/1516375842496",
RawPath: "",
ForceQuery: false,
RawQuery: "",
Fragment: "",
},
why Host & Scheme are empty?
because your RequestURI is relative.
because your RequestURI is relative.
what does that mean?
because your RequestURI is relative.
so how can i get the absolute_uri?
hello,
Why the url struct from *gin.context request is empty in localhost ??
I'm accessing this url in my server: http://local.mininoticias.com.ar:8084/
If I print
fmt.Println("request url:", c.Request.URL)
fmt.Println("request host:", c.Request.Host)
I get:
request url: /
request host: local.mininoticias.com.ar:8084
So no host, scheme or anything in the url struct
Not sure why this issue was closed without any explanation
I'd love to have an answer as well. At least c.Request.Host seems to be correct, but I just have to guess the Scheme. And yes, the call was a relative URI — so what?
Ok, it seems that this was closed because it's not an issue with Gin, but with the weird way the underlying http library works: https://stackoverflow.com/questions/6899069/why-are-request-url-host-and-scheme-blank-in-the-development-server
The comments there give some ideas on how to extract the relevant data _if_ the call is a relative call...
I guess that's why this issue was closed.
Most helpful comment
so how can i get the absolute_uri?