SocketHandshake
Technical reference of SocketHandshake.
This API is used in WebSocket requests.
Symbols
| Symbol | Class | Description |
|---|---|---|
| SocketHandshake | type | SocketHandshake defines a public type of API. |
| NewSocketHandshake | func | Build NewSocketHandshake. |
| SocketHandshake.Headers.Get | func | It gets the first value associated with a key. |
| SocketHandshake.Headers.GetAll | func | It gets all the values associated with a key. |
| SocketHandshake.Headers.Has | func | It indicates whether the collection contains the key. |
| SocketHandshake.Method | func | Returns the HTTP method or the solved method name. |
| SocketHandshake.IP | func | Returns the IP address resolved for the client. |
| SocketHandshake.IsSecure | func | It indicates whether the request uses safe transport. |
| SocketHandshake.Origin | func | Returns schema and authority. |
| SocketHandshake.UserAgent | func | Return the header User-Agent Handshake. |
SocketHandshake
Declaration:
type SocketHandshake struct {
URL URL
Headers Collection[string]
Cookies Collection[string]
Query Collection[string]
} SocketHandshake defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
URL | URL | Structured request URL. |
Headers | Collection[string] | Header collection. |
Cookies | Collection[string] | Cookie collection. |
Query | Collection[string] | query parameters. |
NewSocketHandshake
Declaration:
func NewSocketHandshake(request Request) SocketHandshake Build NewSocketHandshake.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | Request | Type value Request required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | SocketHandshake | Type value SocketHandshake produced by the operation. |
Usage syntax
value := gox.NewSocketHandshake(ctx.Request) SocketHandshake.Headers.Get
Declaration:
func (headers socketHandshakeHeaders) Get(key string) (string, bool) It gets the first value associated with a key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
ok | bool | It indicates the result of the check. |
Behavior
When the key does not exist, it returns the zero value of T and false.
Usage syntax
value, ok := socketHandshake.Headers.Get("key") SocketHandshake.Headers.GetAll
Declaration:
func (headers socketHandshakeHeaders) GetAll(key string) ([]string, bool) It gets all the values associated with a key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | []string | Result collection; can be nil when there are no values. |
ok | bool | It indicates the result of the check. |
Behavior
The returned slice is independent of the collection. When the key does not exist, it returns nil and false.
Usage syntax
value, ok := socketHandshake.Headers.GetAll("key") SocketHandshake.Headers.Has
Declaration:
func (headers socketHandshakeHeaders) Has(key string) bool It indicates whether the collection contains the key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := socketHandshake.Headers.Has("key") SocketHandshake.Method
Declaration:
func (handshake SocketHandshake) Method() string Returns the HTTP method or the solved method name.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := socket.Handshake.Method() SocketHandshake.IP
Declaration:
func (handshake SocketHandshake) IP() string Returns the IP address resolved for the client.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := socket.Handshake.IP() SocketHandshake.IsSecure
Declaration:
func (handshake SocketHandshake) IsSecure() bool It indicates whether the request uses safe transport.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := socket.Handshake.IsSecure() SocketHandshake.Origin
Declaration:
func (handshake SocketHandshake) Origin() string Returns schema and authority.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := socket.Handshake.Origin() SocketHandshake.UserAgent
Declaration:
func (handshake SocketHandshake) UserAgent() string Return the header User-Agent Handshake.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := socket.Handshake.UserAgent()