Documentation
¶
Index ¶
- type AfterFunc
- type App
- func (server *App) After(path string, afterFunc AfterFunc)
- func (server *App) Before(path string, beforeFunc BeforeFunc)
- func (server *App) Delete(path string, handler HandlerFunc) *App
- func (server *App) Events(eventFunc func(serverEvents *ServerEvents)) *App
- func (server *App) Get(path string, handler HandlerFunc) *App
- func (server *App) HTTPServe(path string, httpServeFunc ServeHTTPFunc)
- func (server *App) Head(path string, handler HandlerFunc) *App
- func (server *App) Options(path string, handler HandlerFunc) *App
- func (server *App) Patch(path string, handler HandlerFunc) *App
- func (server *App) Port() uint16
- func (server *App) Post(path string, handler HandlerFunc) *App
- func (server *App) Put(path string, handler HandlerFunc) *App
- func (server *App) Route(path string, scopeFunc func()) *App
- func (server *App) Shutdown() error
- func (server *App) Start(port ...uint16) error
- func (server *App) Static(path string, staticHandlerFunc StaticHandlerFunc) *App
- func (server *App) Ws(path string, handlerFunc WsHandlerFunc) *App
- type BeforeFunc
- type BodyFieldValidator
- func (f *BodyFieldValidator) Custom(validatorFn func(interface{}) bool, message string) *BodyFieldValidator
- func (f *BodyFieldValidator) Email() *BodyFieldValidator
- func (f *BodyFieldValidator) Get() *BodyValidator
- func (f *BodyFieldValidator) Max(maximum int) *BodyFieldValidator
- func (f *BodyFieldValidator) MaxLength(maximum int) *BodyFieldValidator
- func (f *BodyFieldValidator) Min(minimum int) *BodyFieldValidator
- func (f *BodyFieldValidator) MinLength(minimum int) *BodyFieldValidator
- func (f *BodyFieldValidator) Required() *BodyFieldValidator
- type BodyValidator
- type Call
- func (call *Call) Authorization() string
- func (call *Call) BodyAs(obj any) error
- func (call *Call) Cookie(name string, cookies ...*http.Cookie) (*http.Cookie, error)
- func (call *Call) Error(err error)
- func (call *Call) File(key string) (*multipart.FileHeader, error)
- func (call *Call) Files(key string) ([]*multipart.FileHeader, error)
- func (call *Call) FormParam(key string) (string, error)
- func (call *Call) FormParamOrDefault(key string, def string) string
- func (call *Call) FormParams() (url.Values, error)
- func (call *Call) HTML(text string)
- func (call *Call) Header(key string, value ...string) string
- func (call *Call) HeaderOrDefault(key string, def string) string
- func (call *Call) Host() string
- func (call *Call) ID() string
- func (call *Call) JSON(obj interface{})
- func (call *Call) Method() string
- func (call *Call) PathParam(key string) string
- func (call *Call) PathParams() map[string]string
- func (call *Call) QueryParam(key string) string
- func (call *Call) QueryParamOrDefault(key string, def string) string
- func (call *Call) Redirect(url string, permanent ...bool)
- func (call *Call) Referer() string
- func (call *Call) SessionAttr(key string, value ...any) (any, error)
- func (call *Call) SessionAttrOrDefault(key string, def any) any
- func (call *Call) Status(statusCode ...int) int
- func (call *Call) Text(text string)
- func (call *Call) URL() *url.URL
- func (call *Call) UserAgent() string
- func (call *Call) ValidatedBody(target interface{}) *BodyValidator
- func (call *Call) ValidatedFormParam(key string) *StringValidator
- func (call *Call) ValidatedFormParamAsInt(key string) *IntValidator
- func (call *Call) ValidatedPathParam(key string) *StringValidator
- func (call *Call) ValidatedPathParamAsInt(key string) *IntValidator
- func (call *Call) ValidatedQueryParam(key string) *StringValidator
- func (call *Call) ValidatedQueryParamAsInt(key string) *IntValidator
- type Config
- func (config *Config) EnableAccessLog(enabled bool) *Config
- func (config *Config) EnableSessions(confFunc ...SessionConfigFunc) *Config
- func (config *Config) EnableStartupLog(enabled bool) *Config
- func (config *Config) Events(eventFunc func(serverEvents *ServerEvents)) *Config
- func (config *Config) Plugin(plugin Plugin) *Config
- func (config *Config) Port(port uint16) *Config
- func (config *Config) ServerMaxBodyReadSize(maxReadSize int64) *Config
- func (config *Config) ServerMaxReadTimeout(timeout int64) *Config
- func (config *Config) ServerShutdownTimeout(timeout int64) *Config
- type ConfigFunc
- type HandlerFunc
- type IntValidator
- type OnRouteAdded
- type OnServerShutdown
- type OnServerStartup
- type Plugin
- type ServeHTTPFunc
- type ServerEvents
- type SessionConfigFunc
- type SessionConfiguration
- type StaticConfig
- type StaticHandlerFunc
- type StringValidator
- func (v *StringValidator) Custom(fn func(string) bool, message string) *StringValidator
- func (v *StringValidator) Email() *StringValidator
- func (v *StringValidator) Get() (string, error)
- func (v *StringValidator) MaxLength(maximum int) *StringValidator
- func (v *StringValidator) MinLength(minimum int) *StringValidator
- func (v *StringValidator) Required() *StringValidator
- type WsConfig
- type WsConnection
- type WsHandlerFunc
- type WsMessage
- func (message *WsMessage) As(jsonStruct interface{}) error
- func (message *WsMessage) AsBytes() []byte
- func (message *WsMessage) AsText() string
- func (message *WsMessage) Reply(json interface{}) error
- func (message *WsMessage) ReplyBytes(bytes []byte) error
- func (message *WsMessage) ReplyText(text string) error
- type WsOnCloseFunc
- type WsOnErrorFunc
- type WsOnMessageFunc
- type WsOnOpenFunc
- type WsOnUpgradeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) After ¶
Add an after handler to given path
Add an after handler that will run after any endpoint handler which matches the same request.
func (*App) Before ¶
func (server *App) Before(path string, beforeFunc BeforeFunc)
Add a before handler to given path
Add a before handler that will run before any endpoint handler which matches the same request. If the before handler returns false, the request will be short circuited.
func (*App) Delete ¶ added in v0.0.6
func (server *App) Delete(path string, handler HandlerFunc) *App
Add a DELETE handler
Add a DELETE handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) Events ¶ added in v0.2.11
func (server *App) Events(eventFunc func(serverEvents *ServerEvents)) *App
Events allows you to subscribe to server events such as startup and shutdown on an already constructed App.
This is the post-construction counterpart of Config.Events, for apps built elsewhere (e.g. by an application constructor or a test harness). Must be called before Start; late registrations are ignored with a warning, since Start reads the event lists without synchronization.
func (*App) Get ¶
func (server *App) Get(path string, handler HandlerFunc) *App
Add a GET handler
Add a GET handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) HTTPServe ¶ added in v0.2.3
func (server *App) HTTPServe(path string, httpServeFunc ServeHTTPFunc)
HttpServe registers a ServeHttpFunc to a path which adheres to the http.Handler interface.
func (*App) Head ¶
func (server *App) Head(path string, handler HandlerFunc) *App
Add a HEAD handler
Add a HEAD handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) Options ¶
func (server *App) Options(path string, handler HandlerFunc) *App
Add a OPTIONS handler
Add a OPTIONS handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) Patch ¶
func (server *App) Patch(path string, handler HandlerFunc) *App
Add a PATCH handler
Add a PATCH handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) Port ¶ added in v0.2.9
Port returns the port the server is bound to.
After Start, this is the port the listener is actually bound to, read from the live listener — so when the server is started on port 0 (OS-assigned ephemeral port) this returns the real assigned port, not 0. Before Start is called it returns the zero value.
func (*App) Post ¶
func (server *App) Post(path string, handler HandlerFunc) *App
Add a POST handler
Add a POST handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) Put ¶
func (server *App) Put(path string, handler HandlerFunc) *App
Add a PUT handler
Add a PUT handler based on where you are in a hierarchy composed from other method handlers or route handlers.
func (*App) Route ¶
Add a route to the given path
Add a route which provides a scoped route function for which you can add methods or even more routes into. This allows for hierarchical building of routes and methods.
func (*App) Shutdown ¶
Shutdown the govalin server
Start a graceful shutdown of the govalin instance.
type BeforeFunc ¶
type BodyFieldValidator ¶ added in v0.2.4
type BodyFieldValidator struct {
// contains filtered or unexported fields
}
BodyFieldValidator allows chaining validation rules for a specific field.
func (*BodyFieldValidator) Custom ¶ added in v0.2.4
func (f *BodyFieldValidator) Custom(validatorFn func(interface{}) bool, message string) *BodyFieldValidator
Custom adds a custom validation rule for the current field.
func (*BodyFieldValidator) Email ¶ added in v0.2.4
func (f *BodyFieldValidator) Email() *BodyFieldValidator
Email adds an email validation rule for string fields.
func (*BodyFieldValidator) Get ¶ added in v0.2.4
func (f *BodyFieldValidator) Get() *BodyValidator
Get completes the field validation and returns the body validator for more fields or final validation.
func (*BodyFieldValidator) Max ¶ added in v0.2.4
func (f *BodyFieldValidator) Max(maximum int) *BodyFieldValidator
Max adds a maximum value validation rule for integer fields.
func (*BodyFieldValidator) MaxLength ¶ added in v0.2.4
func (f *BodyFieldValidator) MaxLength(maximum int) *BodyFieldValidator
MaxLength adds a maximum length validation rule for string fields.
func (*BodyFieldValidator) Min ¶ added in v0.2.4
func (f *BodyFieldValidator) Min(minimum int) *BodyFieldValidator
Min adds a minimum value validation rule for integer fields.
func (*BodyFieldValidator) MinLength ¶ added in v0.2.4
func (f *BodyFieldValidator) MinLength(minimum int) *BodyFieldValidator
MinLength adds a minimum length validation rule for string fields.
func (*BodyFieldValidator) Required ¶ added in v0.2.4
func (f *BodyFieldValidator) Required() *BodyFieldValidator
Required adds a required validation rule for the current field.
type BodyValidator ¶ added in v0.2.4
type BodyValidator struct {
// contains filtered or unexported fields
}
BodyValidator provides validation for request body.
func (*BodyValidator) AddRule ¶ added in v0.2.4
func (v *BodyValidator) AddRule(rule func(interface{}) error)
AddRule adds a validation rule to the body validator (implements interface for validation package).
func (*BodyValidator) Custom ¶ added in v0.2.4
func (v *BodyValidator) Custom(validatorFn func(interface{}) bool, message string) *BodyValidator
Custom adds a custom validation rule for the entire body with type safety.
func (*BodyValidator) Get ¶ added in v0.2.4
func (v *BodyValidator) Get() error
Get validates the body and returns error if invalid.
func (*BodyValidator) ValidateField ¶ added in v0.2.4
func (v *BodyValidator) ValidateField(fieldName string) *BodyFieldValidator
ValidateField sets the current field for validation and returns a BodyFieldValidator.
type Call ¶
type Call struct {
Raw raw // Raw contains the raw request and response
// contains filtered or unexported fields
}
Call is used to interact with the request and response object
It exposes several convenience methods for handling both path, query as well as body for the request. It follows simple conventions for getting and setting values and uses the same method for getting values from the request and setting values on the response by having optional values.
func (*Call) Authorization ¶ added in v0.1.2
Authorization returns the Authorization header if available.
func (*Call) BodyAs ¶
Get body as given struct
BodyAs takes a pointer as input and tries to deserialize the body into the object expecting the body to be JSON. Returns an error on failed unmarshalling or non-pointer.
func (*Call) Cookie ¶ added in v0.1.2
Get or set a Cookie by name and value
Get a Cookie based on given Cookie name request or set a Cookie on the response by providing a value.
func (*Call) Error ¶
Handle an error
Write a response based on given error. If the error is recognized as a govalin error the error is handled specific according to the error.
func (*Call) File ¶ added in v0.1.0
func (call *Call) File(key string) (*multipart.FileHeader, error)
File returns a FileHeader for given file name in the request body.
func (*Call) Files ¶ added in v0.1.0
func (call *Call) Files(key string) ([]*multipart.FileHeader, error)
Files returns an array for the given file name in the request body.
func (*Call) FormParam ¶
Get the value of given form param key
Parses the body as a www-form-urlencoded body. If the content type is not correct a warning is given and an empty string is returned.
func (*Call) FormParamOrDefault ¶
Get form param value by key, if empty, use default
Get a form param value based on given key from the request, or use the given default value if the value is an empty string.
func (*Call) FormParams ¶ added in v0.1.0
FormParams returns all form parameters available in the request body.
func (*Call) HTML ¶
Send text as HTML to response
HTML will set the content-type of the response as text/html and write it to the response. If no other status has been given the response, it will write a 200 OK to the response.
func (*Call) Header ¶
Get or set header by given key and value
Get a header value based on given header key from the request or set header value on the response by providing a value.
func (*Call) HeaderOrDefault ¶
Get header value by key, if empty, use default
Get a header value based on given header key from the request, or use the given default value if the value is an empty string.
func (*Call) JSON ¶
func (call *Call) JSON(obj interface{})
Send obj as JSON to response
JSON will set the content-type of the response as application/json and serializes the given object as JSON, and writes it to the response. If no other status has been given the response, it will write a 200 OK to the response.
func (*Call) PathParams ¶
Get all path params as a map
Returns a map populated with the values based on the configuration of the path URL as a map[string]string.
func (*Call) QueryParamOrDefault ¶
Get query param by key, if empty, use default
Returns the query param value as string or use the given default value if the value is an empty string.
func (*Call) Redirect ¶ added in v0.2.0
Redirect redirects the request to the given URL
Redirect will set the status code to 302 or 301 (if permenant) and set the location header to the given URL.
func (*Call) Referer ¶ added in v0.1.2
Referer returns the requests referer header if available. Also handles the edge case if the name of the header names spelling is correct (referrer).
func (*Call) SessionAttr ¶ added in v0.2.0
Get or set a session attribute by key and value
Get or set a session attribute based on given key from the request. The session attribute will be stored in the session store and will be available for the next request. If no value is given, it will return the value of the session attribute. If the session attribute is not found, an error will be returned.
func (*Call) SessionAttrOrDefault ¶ added in v0.2.0
Get a session attribute by key or default value
Get a session attribute based on given key from the request. The session attribute is stored in the session store and will be available for the next request. If the session attribute is not found, the default value will be returned.
func (*Call) Status ¶
Set HTTP status that will be used on the response
The status is buffered on the call and committed to the response on the first body write (JSON/Text/HTML/Redirect) or, if no body is written, once at the end of the request lifecycle. Setting a status alone is therefore enough to send it. Requests that take over the raw writer (HTTPServe) are never flushed by the framework.
func (*Call) Text ¶
Send text as pure text to response
Text will set the content-type of the response as text/plain and write it to the response. If no other status has been given the response, it will write a 200 OK to the response.
func (*Call) ValidatedBody ¶ added in v0.2.4
func (call *Call) ValidatedBody(target interface{}) *BodyValidator
ValidatedBody returns a curryable body validator.
func (*Call) ValidatedFormParam ¶ added in v0.2.4
func (call *Call) ValidatedFormParam(key string) *StringValidator
ValidatedFormParam returns a curryable string validator for form parameters.
func (*Call) ValidatedFormParamAsInt ¶ added in v0.2.4
func (call *Call) ValidatedFormParamAsInt(key string) *IntValidator
ValidatedFormParamAsInt returns a curryable integer validator for form parameters.
func (*Call) ValidatedPathParam ¶ added in v0.2.4
func (call *Call) ValidatedPathParam(key string) *StringValidator
ValidatedPathParam returns a curryable string validator for path parameters.
func (*Call) ValidatedPathParamAsInt ¶ added in v0.2.4
func (call *Call) ValidatedPathParamAsInt(key string) *IntValidator
ValidatedPathParamAsInt returns a curryable integer validator for path parameters.
func (*Call) ValidatedQueryParam ¶ added in v0.2.4
func (call *Call) ValidatedQueryParam(key string) *StringValidator
ValidatedQueryParam returns a curryable string validator for query parameters.
func (*Call) ValidatedQueryParamAsInt ¶ added in v0.2.4
func (call *Call) ValidatedQueryParamAsInt(key string) *IntValidator
ValidatedQueryParamAsInt returns a curryable integer validator for query parameters.
type Config ¶ added in v0.1.0
type Config struct {
// contains filtered or unexported fields
}
Config contains configuration for a Govalin instance.
func (*Config) EnableAccessLog ¶ added in v0.2.1
EnableAccessLog enables access logging for the server. Default is enabled.
func (*Config) EnableSessions ¶ added in v0.2.0
func (config *Config) EnableSessions(confFunc ...SessionConfigFunc) *Config
EnableSessions configures govalin to use sessions for all requests.
func (*Config) EnableStartupLog ¶ added in v0.2.1
func (*Config) Events ¶ added in v0.2.2
func (config *Config) Events(eventFunc func(serverEvents *ServerEvents)) *Config
Events allows you to subscribe to server events such as startup and shutdown on the Govalin instance.
func (*Config) Plugin ¶ added in v0.1.0
Plugin lets you to provide a Plugin that can interact on the Govalin instance.
func (*Config) ServerMaxBodyReadSize ¶ added in v0.1.0
ServerMaxBodyReadSize sets the max read size to accept from POST requests.
The server will error if the body size is too big and refuse to handle the request further. This is to control DDoS attacks using big body sizes.
func (*Config) ServerMaxReadTimeout ¶ added in v0.1.0
ServerMaxReadTimeout sets the max read timeout for requests towards the Govalin server.
func (*Config) ServerShutdownTimeout ¶ added in v0.1.0
ServerShutdownTimeout sets the max timeout for before forcefully shutting the server down.
type ConfigFunc ¶ added in v0.1.0
type ConfigFunc func(config *Config)
ConfigFunc gives a config function that will generate a Config for the Govalin object.
type HandlerFunc ¶
type HandlerFunc func(call *Call)
type IntValidator ¶ added in v0.2.4
type IntValidator struct {
// contains filtered or unexported fields
}
IntValidator provides a curryable integer validation interface.
func (*IntValidator) Custom ¶ added in v0.2.4
func (v *IntValidator) Custom(fn func(int) bool, message string) *IntValidator
Custom adds a custom validation rule for integers.
func (*IntValidator) Get ¶ added in v0.2.4
func (v *IntValidator) Get() (int, error)
Get validates the integer and returns it if valid.
func (*IntValidator) Max ¶ added in v0.2.4
func (v *IntValidator) Max(maximum int) *IntValidator
Max adds a maximum value validation rule for integers.
func (*IntValidator) Min ¶ added in v0.2.4
func (v *IntValidator) Min(minimum int) *IntValidator
Min adds a minimum value validation rule for integers.
func (*IntValidator) Range ¶ added in v0.2.4
func (v *IntValidator) Range(minimum, maximum int) *IntValidator
Range adds a range validation rule for integers.
type OnRouteAdded ¶ added in v0.2.2
type OnRouteAdded func(method string, path string, handler HandlerFunc)
type OnServerShutdown ¶ added in v0.2.2
type OnServerShutdown func()
type OnServerStartup ¶ added in v0.2.2
type OnServerStartup func()
type Plugin ¶ added in v0.1.0
type Plugin interface {
// Name should return the name of the plugin for logging and debugging
// purposes
Name() string
// OnInit supplies the configuraiton will be run before any handlers are
// added
OnInit(*Config)
// Apply will provide the Plugin with the Govalin app instance so it can
// add new routes or act upon the Govalin instance in other plugin'y ways.
Apply(app *App)
}
Plugin is a way of interacting on a Govalin instance.
type ServeHTTPFunc ¶ added in v0.2.3
type ServeHTTPFunc func(w http.ResponseWriter, r *http.Request)
type ServerEvents ¶ added in v0.2.2
type ServerEvents struct {
// contains filtered or unexported fields
}
func (*ServerEvents) AddOnRouteAdded ¶ added in v0.2.2
func (events *ServerEvents) AddOnRouteAdded(event OnRouteAdded)
func (*ServerEvents) AddOnServerShutdown ¶ added in v0.2.2
func (events *ServerEvents) AddOnServerShutdown(event OnServerShutdown)
func (*ServerEvents) AddOnServerStartup ¶ added in v0.2.2
func (events *ServerEvents) AddOnServerStartup(event OnServerStartup)
type SessionConfigFunc ¶ added in v0.2.0
type SessionConfigFunc func(sessionConfig *SessionConfiguration)
type SessionConfiguration ¶ added in v0.2.0
type SessionConfiguration struct {
// contains filtered or unexported fields
}
func (*SessionConfiguration) SessionExpireTime ¶ added in v0.2.0
func (config *SessionConfiguration) SessionExpireTime(expireTime time.Duration) *SessionConfiguration
SessionExpireTime sets the expire time for sessions.
func (*SessionConfiguration) SessionStore ¶ added in v0.2.0
func (config *SessionConfiguration) SessionStore(store session.Store) *SessionConfiguration
SessionStore sets the session store to use.
type StaticConfig ¶ added in v0.2.1
type StaticConfig struct {
// contains filtered or unexported fields
}
StaticConfig contains configuration for a static handler.
func (*StaticConfig) EnableSPAMode ¶ added in v0.2.1
func (config *StaticConfig) EnableSPAMode(spaMode bool) *StaticConfig
EnableSPAMode enables SPA mode for the static handler.
SPA mode will serve the index.html file for all requests that doesn't match a static file.
func (*StaticConfig) HostPath ¶ added in v0.2.1
func (config *StaticConfig) HostPath(hostPath string) *StaticConfig
HostPath sets the host path for the static handler. This is trimmed from the URL before serving the static files.
func (*StaticConfig) WithFS ¶ added in v0.2.1
func (config *StaticConfig) WithFS(fsContent fs.FS) *StaticConfig
WithFS sets the bundled FS to serve static files from.
func (*StaticConfig) WithStaticPath ¶ added in v0.2.1
func (config *StaticConfig) WithStaticPath(staticPath string) *StaticConfig
WithStaticPath sets the path to a directory containing static files.
The directory will be served at the given path, relative to where the server is started.
type StaticHandlerFunc ¶ added in v0.2.1
type StaticHandlerFunc func(call *Call, staticConfig *StaticConfig)
type StringValidator ¶ added in v0.2.4
type StringValidator struct {
// contains filtered or unexported fields
}
StringValidator provides a curryable string validation interface.
func (*StringValidator) Custom ¶ added in v0.2.4
func (v *StringValidator) Custom(fn func(string) bool, message string) *StringValidator
Custom adds a custom validation rule for strings.
func (*StringValidator) Email ¶ added in v0.2.4
func (v *StringValidator) Email() *StringValidator
Email adds an email validation rule.
func (*StringValidator) Get ¶ added in v0.2.4
func (v *StringValidator) Get() (string, error)
Get validates the string and returns it if valid.
func (*StringValidator) MaxLength ¶ added in v0.2.4
func (v *StringValidator) MaxLength(maximum int) *StringValidator
MaxLength adds a maximum length validation rule.
func (*StringValidator) MinLength ¶ added in v0.2.4
func (v *StringValidator) MinLength(minimum int) *StringValidator
MinLength adds a minimum length validation rule.
func (*StringValidator) Required ¶ added in v0.2.4
func (v *StringValidator) Required() *StringValidator
Required adds a required validation rule.
type WsConfig ¶ added in v0.2.1
type WsConfig struct {
// OnUpgrade is called when a websocket connection is upgraded.
OnUpgrade WsOnUpgradeFunc
// OnOpen is called when a websocket connection is opened.
OnOpen WsOnOpenFunc
// OnMessage is called when a message is received from the client.
OnMessage WsOnMessageFunc
// OnClose is called when a websocket connection is closed.
OnClose WsOnCloseFunc
// OnError is called when an error occurs.
OnError WsOnErrorFunc
}
WsConfig contains configuration for a websocket handler.
type WsConnection ¶ added in v0.2.1
type WsConnection struct {
// contains filtered or unexported fields
}
WsConnection is a connection to a websocket.
func (*WsConnection) Close ¶ added in v0.2.1
func (wsConnection *WsConnection) Close() error
Close closes the websocket connection.
func (*WsConnection) Send ¶ added in v0.2.1
func (wsConnection *WsConnection) Send(json interface{}) error
Send sends a JSON message to the client.
func (*WsConnection) SendBytes ¶ added in v0.2.1
func (wsConnection *WsConnection) SendBytes(bytes []byte) error
SendBytes sends a binary message to the client.
func (*WsConnection) SendText ¶ added in v0.2.1
func (wsConnection *WsConnection) SendText(text string) error
SendText sends a text message to the client.
type WsHandlerFunc ¶ added in v0.2.1
type WsHandlerFunc func(wsConfig *WsConfig)
type WsMessage ¶ added in v0.2.1
type WsMessage struct {
// contains filtered or unexported fields
}
WsMessage is a message received from a websocket.
func (*WsMessage) ReplyBytes ¶ added in v0.2.1
ReplyBytes sends a reply to the client of the message.
type WsOnCloseFunc ¶ added in v0.2.1
type WsOnErrorFunc ¶ added in v0.2.1
type WsOnErrorFunc func(err error)
type WsOnMessageFunc ¶ added in v0.2.1
type WsOnMessageFunc func(wsMessage *WsMessage)
type WsOnOpenFunc ¶ added in v0.2.1
type WsOnOpenFunc func(wsConnection *WsConnection)
type WsOnUpgradeFunc ¶ added in v0.2.1
type WsOnUpgradeFunc func(call *Call) (*WsConnection, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package govalintest provides a test harness for testing govalin applications over real HTTP.
|
Package govalintest provides a test harness for testing govalin applications over real HTTP. |
|
internal
|
|
|
session
Package session provides an interface for managing user sessions.
|
Package session provides an interface for managing user sessions. |
|
plugins
|
|
|
mdns
Package mdns provides an opt-in GOVALIN plugin that advertises the running server on the local network as a DNS-SD `_http._tcp` service over multicast DNS (Bonjour/Zeroconf).
|
Package mdns provides an opt-in GOVALIN plugin that advertises the running server on the local network as a DNS-SD `_http._tcp` service over multicast DNS (Bonjour/Zeroconf). |
|
Package validation provides advanced validation constructors and rules for complex validation scenarios.
|
Package validation provides advanced validation constructors and rules for complex validation scenarios. |