[MM-37772] Idiomatic naming (URL, URI, API) (#18128)

* s/Url/URL/g & s/Uri/URI/g

* s/Api/API/g
Этот коммит содержится в:
Ben Schumacher
2021-08-16 19:46:44 +02:00
коммит произвёл GitHub
родитель a7f5512ff3
Коммит 757dc96461
155 изменённых файлов: 1680 добавлений и 1681 удалений

Просмотреть файл

@@ -37,9 +37,9 @@ const avgReadMsgSizeBytes = 1024
// A client must read from PingTimeoutChannel, EventChannel and ResponseChannel to prevent
// deadlocks from occurring in the program.
type WebSocketClient struct {
Url string // The location of the server like "ws://localhost:8065"
ApiUrl string // The API location of the server like "ws://localhost:8065/api/v3"
ConnectUrl string // The WebSocket URL to connect to like "ws://localhost:8065/api/v3/path/to/websocket"
URL string // The location of the server like "ws://localhost:8065"
APIURL string // The API location of the server like "ws://localhost:8065/api/v3"
ConnectURL string // The WebSocket URL to connect to like "ws://localhost:8065/api/v3/path/to/websocket"
Conn *websocket.Conn // The WebSocket connection
AuthToken string // The token used to open the WebSocket connection
Sequence int64 // The ever-incrementing sequence attached to each WebSocket action
@@ -66,15 +66,15 @@ func NewWebSocketClient(url, authToken string) (*WebSocketClient, error) {
// NewWebSocketClientWithDialer constructs a new WebSocket client with convenience
// methods for talking to the server using a custom dialer.
func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, error) {
conn, _, err := dialer.Dial(url+ApiUrlSuffix+"/websocket", nil)
conn, _, err := dialer.Dial(url+APIURLSuffix+"/websocket", nil)
if err != nil {
return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
client := &WebSocketClient{
Url: url,
ApiUrl: url + ApiUrlSuffix,
ConnectUrl: url + ApiUrlSuffix + "/websocket",
URL: url,
APIURL: url + APIURLSuffix,
ConnectURL: url + APIURLSuffix + "/websocket",
Conn: conn,
AuthToken: authToken,
Sequence: 1,
@@ -107,17 +107,17 @@ func NewWebSocketClient4WithDialer(dialer *websocket.Dialer, url, authToken stri
return NewWebSocketClientWithDialer(dialer, url, authToken)
}
// Connect creates a websocket connection with the given ConnectUrl.
// Connect creates a websocket connection with the given ConnectURL.
// This is racy and error-prone should not be used. Use any of the New* functions to create a websocket.
func (wsc *WebSocketClient) Connect() *AppError {
return wsc.ConnectWithDialer(websocket.DefaultDialer)
}
// ConnectWithDialer creates a websocket connection with the given ConnectUrl using the dialer.
// ConnectWithDialer creates a websocket connection with the given ConnectURL using the dialer.
// This is racy and error-prone and should not be used. Use any of the New* functions to create a websocket.
func (wsc *WebSocketClient) ConnectWithDialer(dialer *websocket.Dialer) *AppError {
var err error
wsc.Conn, _, err = dialer.Dial(wsc.ConnectUrl, nil)
wsc.Conn, _, err = dialer.Dial(wsc.ConnectURL, nil)
if err != nil {
return NewAppError("Connect", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}