Request
Request represents the normalized HTTP request and exposes its URL, path, collections, form, and body.
This API is used in Request, Routes.
Symbols
| Symbol | Class | Description |
|---|---|---|
| Request | type | Request defines a public type of API. |
| FormData | type | Build a body multipart/form-data. |
| RequestInput | type | RequestInput defines a public type of API. |
| NewRequest | func | Build NewRequest. |
| Request.Method | func | Returns the HTTP method or the solved method name. |
| Request.IP | func | Returns the IP address resolved for the client. |
| Request.IsSecure | func | It indicates whether the request uses safe transport. |
| Request.ContentType | func | Return the MIME type. |
| URL | type | URL defines a public type of API. |
| URLInput | type | URLInput defines a public type of API. |
| NewURL | func | Build NewURL. |
| URL.String | func | Returns the full textual representation. |
| URL.Scheme | func | Returns the URL schema. |
| URL.Host | func | Return host and port. |
| URL.Hostname | func | Return the hostname without port. |
| URL.Port | func | Return the explicit port. |
| URL.Path | func | Returns the standard route. |
| URL.RawPath | func | Returns the original encoded route. |
| URL.QueryString | func | Returns the query string without analysis. |
| URL.Origin | func | Returns schema and authority. |
| Route | type | Route defines a public type of API. |
| RouteInput | type | RouteInput defines a public type of API. |
| NewRoute | func | Build NewRoute. |
| Route.IsMatched | func | It indicates whether a set-up rule produced the route. |
| Route.Original | func | Returns the requested route before the resolution. |
| Route.Target | func | Returns the resolved internal destination. |
| Route.Pattern | func | Returns the pattern that produced the coincidence. |
| Route.Method | func | Returns the HTTP method or the solved method name. |
| Route.IsStatic | func | It indicates if the destination is a static file. |
| Route.IsAction | func | It indicates if the fate is an Action. |
| Route.IsClientAsset | func | It indicates whether the destination belongs to a Client component. |
| Entry | type | Entry defines a public type of API. |
| Collection | type | Collection defines a public type of API. |
| NewCollection | func | Build NewCollection. |
| NewCollectionView | func | Build NewCollectionView. |
| Collection.Get | func | It gets the first value associated with a key. |
| Collection.GetAll | func | It gets all the values associated with a key. |
| Collection.Has | func | It indicates whether the collection contains the key. |
| Collection.IsEmpty | func | It indicates whether the collection does not contain values. |
| Collection.Count | func | Returns the number of keys or elements available. |
| Collection.Keys | func | Returns the available keys. |
| Collection.Values | func | Returns a copy of the values grouped by key. |
| Collection.Entries | func | Return the tickets to the collection. |
| NewHeaders | func | Build NewHeaders. |
| NewCookies | func | Build NewCookies. |
Request
Declaration:
type Request struct {
URL URL
Headers Collection[string]
Cookies Collection[string]
Query Collection[string]
Form FormData
Route Route
Body Body
} Request 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. |
Form | FormData | Form fields. |
Route | Route | Result of road resolution. |
Body | Body | request body. |
FormData
Declaration:
type FormData struct {
Fields Collection[string]
Files Collection[File]
} Build a body multipart/form-data.
Fields
| Field | Type | Description |
|---|---|---|
Fields | Collection[string] | Text fields. |
Files | Collection[File] | Files received. |
RequestInput
Declaration:
type RequestInput struct {
Method string
IP string
Secure bool
ContentType string
URL URL
Headers Collection[string]
Cookies Collection[string]
Query Collection[string]
Form Collection[string]
Files Collection[File]
Route Route
Body Body
} RequestInput defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Method | string | HTTP method or Action name. |
IP | string | IP address solved. |
Secure | bool | State of safe transport. |
ContentType | string | Half type declared. |
URL | URL | Structured request URL. |
Headers | Collection[string] | Header collection. |
Cookies | Collection[string] | Cookie collection. |
Query | Collection[string] | query parameters. |
Form | Collection[string] | Form fields. |
Files | Collection[File] | Files received. |
Route | Route | Result of road resolution. |
Body | Body | request body. |
NewRequest
Declaration:
func NewRequest(input RequestInput) Request Build NewRequest.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | RequestInput | Data used to build the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | Request | Type value Request produced by the operation. |
Usage syntax
value := gox.NewRequest(gox.RequestInput{}) Request.Method
Declaration:
func (r Request) 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 := ctx.Request.Method() Request.IP
Declaration:
func (r Request) 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 := ctx.Request.IP() Request.IsSecure
Declaration:
func (r Request) 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 := ctx.Request.IsSecure() Request.ContentType
Declaration:
func (r Request) ContentType() string Return the MIME type.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.ContentType() URL
Declaration:
type URL struct {
// contiene campos internos
} URL defines a public type of API.
URLInput
Declaration:
type URLInput struct {
String string
Scheme string
Host string
Hostname string
Port string
Path string
RawPath string
QueryString string
} URLInput defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
String | string | Full URL provided as input. |
Scheme | string | URL outline. |
Host | string | Host, including the port when it exists. |
Hostname | string | Name of host without port. |
Port | string | Explicit URL port. |
Path | string | Route used. |
RawPath | string | Original encoded route. |
QueryString | string | Query string without the leading question mark. |
NewURL
Declaration:
func NewURL(input URLInput) URL Build NewURL.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | URLInput | Data used to build the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | URL | Type value URL produced by the operation. |
Usage syntax
value := gox.NewURL(gox.URLInput{}) URL.String
Declaration:
func (u URL) String() string Returns the full textual representation.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.String() URL.Scheme
Declaration:
func (u URL) Scheme() string Returns the URL schema.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.Scheme() URL.Host
Declaration:
func (u URL) Host() string Return host and port.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.Host() URL.Hostname
Declaration:
func (u URL) Hostname() string Return the hostname without port.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.Hostname() URL.Port
Declaration:
func (u URL) Port() string Return the explicit port.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.Port() URL.Path
Declaration:
func (u URL) Path() string Returns the standard route.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.Path() URL.RawPath
Declaration:
func (u URL) RawPath() string Returns the original encoded route.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.RawPath() URL.QueryString
Declaration:
func (u URL) QueryString() string Returns the query string without analysis.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.URL.QueryString() URL.Origin
Declaration:
func (u URL) 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 := ctx.Request.URL.Origin() Route
Declaration:
type Route struct {
Params Collection[string]
} Route defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Params | Collection[string] | Dynamic parameters of the route. |
RouteInput
Declaration:
type RouteInput struct {
Matched bool
Original string
Target string
Pattern string
Method string
IsStatic bool
IsAction bool
IsClientAsset bool
Params Collection[string]
} RouteInput defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Matched | bool | It indicates if there was a coincidence. |
Original | string | Original route requested. |
Target | string | Destination of the operation. |
Pattern | string | Pattern used for coincidence. |
Method | string | HTTP method or Action name. |
IsStatic | bool | It indicates a static resource. |
IsAction | bool | It indicates an Action. |
IsClientAsset | bool | It indicates an asset of Client component. |
Params | Collection[string] | Dynamic parameters of the route. |
NewRoute
Declaration:
func NewRoute(input RouteInput) Route Build NewRoute.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | RouteInput | Data used to build the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | Route | Type value Route produced by the operation. |
Usage syntax
value := gox.NewRoute(gox.RouteInput{}) Route.IsMatched
Declaration:
func (r Route) IsMatched() bool It indicates whether a set-up rule produced the route.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Request.Route.IsMatched() Route.Original
Declaration:
func (r Route) Original() string Returns the requested route before the resolution.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.Route.Original() Route.Target
Declaration:
func (r Route) Target() string Returns the resolved internal destination.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.Route.Target() Route.Pattern
Declaration:
func (r Route) Pattern() string Returns the pattern that produced the coincidence.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Request.Route.Pattern() Route.Method
Declaration:
func (r Route) 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 := ctx.Request.Route.Method() Route.IsStatic
Declaration:
func (r Route) IsStatic() bool It indicates if the destination is a static file.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Request.Route.IsStatic() Route.IsAction
Declaration:
func (r Route) IsAction() bool It indicates if the fate is an Action.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Request.Route.IsAction() Route.IsClientAsset
Declaration:
func (r Route) IsClientAsset() bool It indicates whether the destination belongs to a Client component.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Request.Route.IsClientAsset() Entry
Declaration:
type Entry[T any] struct {
Key string
Value []T
} Entry defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Key | string | ID key. |
Value | []T | Value stored. |
Collection
Declaration:
type Collection[T any] interface {
Get(key string) (T, bool)
GetAll(key string) ([]T, bool)
Has(key string) bool
IsEmpty() bool
Count() int
Keys() []string
Values() map[string][]T
Entries() []Entry[T]
} Collection defines a public type of API.
NewCollection
Declaration:
func NewCollection[T any](values map[string][]T) Collection[T] Build NewCollection.
Parameters
| Parameter | Type | Description |
|---|---|---|
values | map[string][]T | Values provided to the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Collection[T] | Type value Collection[T] produced by the operation. |
Usage syntax
value := gox.NewCollection(value) NewCollectionView
Declaration:
func NewCollectionView[T any](values map[string][]T) Collection[T] Build NewCollectionView.
Parameters
| Parameter | Type | Description |
|---|---|---|
values | map[string][]T | Values provided to the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Collection[T] | Type value Collection[T] produced by the operation. |
Usage syntax
value := gox.NewCollectionView(value) Collection.Get
Declaration:
func (c collection[T]) Get(key string) (T, 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 | T | Type value T produced by the operation. |
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 := ctx.Request.Headers.Get("key") Collection.GetAll
Declaration:
func (c collection[T]) GetAll(key string) ([]T, 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 | []T | 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 := ctx.Request.Headers.GetAll("key") Collection.Has
Declaration:
func (c collection[T]) 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 := ctx.Request.Headers.Has("key") Collection.IsEmpty
Declaration:
func (c collection[T]) IsEmpty() bool It indicates whether the collection does not contain values.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Request.Headers.IsEmpty() Collection.Count
Declaration:
func (c collection[T]) Count() int Returns the number of keys or elements available.
Returns
| Return | Type | Description |
|---|---|---|
value | int | Type value int produced by the operation. |
Usage syntax
value := ctx.Request.Headers.Count() Collection.Keys
Declaration:
func (c collection[T]) Keys() []string Returns the available keys.
Returns
| Return | Type | Description |
|---|---|---|
value | []string | Result collection; can be nil when there are no values. |
Behavior
The returned slice can be modified without altering the collection.
Usage syntax
value := ctx.Request.Headers.Keys() Collection.Values
Declaration:
func (c collection[T]) Values() map[string][]T Returns a copy of the values grouped by key.
Returns
| Return | Type | Description |
|---|---|---|
value | map[string][]T | Type value map[string][]T produced by the operation. |
Behavior
The returned map is a copy of the visible values.
Usage syntax
value := ctx.Request.Headers.Values() Collection.Entries
Declaration:
func (c collection[T]) Entries() []Entry[T] Return the tickets to the collection.
Returns
| Return | Type | Description |
|---|---|---|
value | []Entry[T] | Result collection; can be nil when there are no values. |
Behavior
Each input retains the key and all its associated values.
Usage syntax
value := ctx.Request.Headers.Entries() NewHeaders
Declaration:
func NewHeaders(values map[string][]string) Collection[string] Build NewHeaders.
Parameters
| Parameter | Type | Description |
|---|---|---|
values | map[string][]string | Values provided to the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Collection[string] | Type value Collection[string] produced by the operation. |
Usage syntax
value := gox.NewHeaders(map[string][]string{}) NewCookies
Declaration:
func NewCookies(values map[string]string) Collection[string] Build NewCookies.
Parameters
| Parameter | Type | Description |
|---|---|---|
values | map[string]string | Values provided to the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Collection[string] | Type value Collection[string] produced by the operation. |
Usage syntax
value := gox.NewCookies(map[string]string{})