URL returns the local base URL of the running server.
()
| 152 | |
| 153 | // URL returns the local base URL of the running server. |
| 154 | func (s *Server) URL() string { |
| 155 | scheme, port := s.Scheme(), s.Port() |
| 156 | |
| 157 | // Use localhost unless a domain is specified. |
| 158 | domain := "localhost" |
| 159 | if s.Domain != "" { |
| 160 | domain = s.Domain |
| 161 | } |
| 162 | |
| 163 | // Return without port if using standard ports. |
| 164 | if (scheme == "http" && port == 80) || (scheme == "https" && port == 443) { |
| 165 | return fmt.Sprintf("%s://%s", s.Scheme(), domain) |
| 166 | } |
| 167 | return fmt.Sprintf("%s://%s:%d", s.Scheme(), domain, s.Port()) |
| 168 | } |
| 169 | |
| 170 | // Open validates the server options and begins listening on the bind address. |
| 171 | func (s *Server) Open() (err error) { |