BaseURL returns (protocol + host + base path).
()
| 108 | |
| 109 | // BaseURL returns (protocol + host + base path). |
| 110 | func (c *DefaultCtx) BaseURL() string { |
| 111 | // TODO: Could be improved: 53.8 ns/op 32 B/op 1 allocs/op |
| 112 | // Should work like https://codeigniter.com/user_guide/helpers/url_helper.html |
| 113 | if c.baseURI != "" { |
| 114 | return c.baseURI |
| 115 | } |
| 116 | scheme := c.Scheme() |
| 117 | host := c.Host() |
| 118 | buf := make([]byte, 0, len(scheme)+len("://")+len(host)) |
| 119 | buf = append(buf, scheme...) |
| 120 | buf = append(buf, "://"...) |
| 121 | buf = append(buf, host...) |
| 122 | c.baseURI = c.app.toString(buf) |
| 123 | return c.baseURI |
| 124 | } |
| 125 | |
| 126 | // RequestCtx returns *fasthttp.RequestCtx that carries a deadline |
| 127 | // a cancellation signal, and other values across API boundaries. |