ResolvePort FIXME ...
(port string, schema string)
| 48 | |
| 49 | // ResolvePort FIXME ... |
| 50 | func ResolvePort(port string, schema string) (string, errors.Error) { |
| 51 | var defaultPorts = map[string]string{ |
| 52 | "http": "80", |
| 53 | "https": "443", |
| 54 | } |
| 55 | if port != "" { |
| 56 | return port, nil |
| 57 | } |
| 58 | if schema != "" { |
| 59 | port, ok := defaultPorts[schema] |
| 60 | if !ok { |
| 61 | return "", errors.Default.New(fmt.Sprintf("schema %s not found", schema)) |
| 62 | } |
| 63 | return port, nil |
| 64 | } |
| 65 | return "", errors.Default.New("you should provide at least one of port or schema") |
| 66 | } |