-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67316ca
commit 6b1ad99
Showing
5 changed files
with
42 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package dial | ||
|
||
import "fmt" | ||
|
||
// Transport is a type, with a restriction on the list of supported connection modes. | ||
type Transport string | ||
|
||
func (t Transport) String() string { | ||
return string(t) | ||
} | ||
|
||
const ( | ||
// TransportDefault used as default value. | ||
TransportDefault Transport = "" | ||
// TransportPlain used for insecure transport mode. | ||
TransportPlain Transport = "plain" | ||
// TransportSSL used for encrypted connection mode. | ||
TransportSSL Transport = "ssl" | ||
// TransportInvalid used to present invalid values. | ||
TransportInvalid Transport = "invalid" | ||
) | ||
|
||
// Parse returns Transport type according to the input string. | ||
func Parse(tr string) (Transport, error) { | ||
switch tr { | ||
case TransportDefault.String(): | ||
return TransportDefault, nil | ||
case TransportPlain.String(): | ||
return TransportPlain, nil | ||
case TransportSSL.String(): | ||
return TransportSSL, nil | ||
default: | ||
return TransportInvalid, fmt.Errorf("unknown Transport type: %s", tr) | ||
} | ||
} |