SocketHandshake

Technical reference of SocketHandshake.

This API is used in WebSocket requests.


Symbols

SymbolClassDescription
SocketHandshaketypeSocketHandshake defines a public type of API.
NewSocketHandshakefuncBuild NewSocketHandshake.
SocketHandshake.Headers.GetfuncIt gets the first value associated with a key.
SocketHandshake.Headers.GetAllfuncIt gets all the values associated with a key.
SocketHandshake.Headers.HasfuncIt indicates whether the collection contains the key.
SocketHandshake.MethodfuncReturns the HTTP method or the solved method name.
SocketHandshake.IPfuncReturns the IP address resolved for the client.
SocketHandshake.IsSecurefuncIt indicates whether the request uses safe transport.
SocketHandshake.OriginfuncReturns schema and authority.
SocketHandshake.UserAgentfuncReturn the header User-Agent Handshake.

SocketHandshake

Declaration:

gox
type SocketHandshake struct {
	URL     URL
	Headers Collection[string]
	Cookies Collection[string]
	Query   Collection[string]
}

SocketHandshake defines a public type of API.

Fields

FieldTypeDescription
URLURLStructured request URL.
HeadersCollection[string]Header collection.
CookiesCollection[string]Cookie collection.
QueryCollection[string]query parameters.

NewSocketHandshake

Declaration:

gox
func NewSocketHandshake(request Request) SocketHandshake

Build NewSocketHandshake.

Parameters

ParameterTypeDescription
requestRequestType value Request required by the operation.

Returns

ReturnTypeDescription
valueSocketHandshakeType value SocketHandshake produced by the operation.

Usage syntax

gox
value := gox.NewSocketHandshake(ctx.Request)

SocketHandshake.Headers.Get

Declaration:

gox
func (headers socketHandshakeHeaders) Get(key string) (string, bool)

It gets the first value associated with a key.

Parameters

ParameterTypeDescription
keystringKey that identifies the value.

Returns

ReturnTypeDescription
valuestringTextual value produced by the operation; its zero value is an empty string.
okboolIt indicates the result of the check.

Behavior

When the key does not exist, it returns the zero value of T and false.

Usage syntax

gox
value, ok := socketHandshake.Headers.Get("key")

SocketHandshake.Headers.GetAll

Declaration:

gox
func (headers socketHandshakeHeaders) GetAll(key string) ([]string, bool)

It gets all the values associated with a key.

Parameters

ParameterTypeDescription
keystringKey that identifies the value.

Returns

ReturnTypeDescription
value[]stringResult collection; can be nil when there are no values.
okboolIt 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

gox
value, ok := socketHandshake.Headers.GetAll("key")

SocketHandshake.Headers.Has

Declaration:

gox
func (headers socketHandshakeHeaders) Has(key string) bool

It indicates whether the collection contains the key.

Parameters

ParameterTypeDescription
keystringKey that identifies the value.

Returns

ReturnTypeDescription
valueboolIt indicates the result of the check.

Usage syntax

gox
value := socketHandshake.Headers.Has("key")

SocketHandshake.Method

Declaration:

gox
func (handshake SocketHandshake) Method() string

Returns the HTTP method or the solved method name.

Returns

ReturnTypeDescription
valuestringTextual value produced by the operation; its zero value is an empty string.

Usage syntax

gox
value := socket.Handshake.Method()

SocketHandshake.IP

Declaration:

gox
func (handshake SocketHandshake) IP() string

Returns the IP address resolved for the client.

Returns

ReturnTypeDescription
valuestringTextual value produced by the operation; its zero value is an empty string.

Usage syntax

gox
value := socket.Handshake.IP()

SocketHandshake.IsSecure

Declaration:

gox
func (handshake SocketHandshake) IsSecure() bool

It indicates whether the request uses safe transport.

Returns

ReturnTypeDescription
valueboolIt indicates the result of the check.

Usage syntax

gox
value := socket.Handshake.IsSecure()

SocketHandshake.Origin

Declaration:

gox
func (handshake SocketHandshake) Origin() string

Returns schema and authority.

Returns

ReturnTypeDescription
valuestringTextual value produced by the operation; its zero value is an empty string.

Usage syntax

gox
value := socket.Handshake.Origin()

SocketHandshake.UserAgent

Declaration:

gox
func (handshake SocketHandshake) UserAgent() string

Return the header User-Agent Handshake.

Returns

ReturnTypeDescription
valuestringTextual value produced by the operation; its zero value is an empty string.

Usage syntax

gox
value := socket.Handshake.UserAgent()

See also

Next step

Continue with collections and socket registration.

Socket collections