Documentation
¶
Overview ¶
Package router provides client-side routing for single-page applications built with GoWebComponents.
This package implements hash-based and history-based routing with support for:
- Multiple router instances
- Browser history integration
- Programmatic navigation
- Nested layout routes with explicit outlets
- Static node and component route registration
- Route-level chunk gates for lazy route artifacts
Basic usage with hash routing:
import (
"github.com/monstercameron/GoWebComponents/v4/html"
"github.com/monstercameron/GoWebComponents/v4/router"
"github.com/monstercameron/GoWebComponents/v4/ui"
)
func main() {
r := router.NewHashRouter()
r.Register("/", HomePage)
r.Register("/about", AboutPage)
r.Register("/contact", ContactPage)
r.Register("*", NotFoundPage)
r.Mount("#app")
}
Route components are regular components:
func HomePage(props router.Attrs) *router.Element {
goAbout := ui.UseEvent(func() {
router.Navigate("/about")
})
return html.Div(html.Props{},
html.H1(html.Props{}, html.Text("Welcome Home")),
html.Button(html.Props{OnClick: goAbout}, html.Text("Go to About")),
)
}
The package supports both hash-based routing (using URL fragments like #/about) and history-based routing (using the HTML5 History API).
Convenience accessors are also available for routed components:
nav := router.UseNavigate()
nav.Navigate("/about")
query := router.UseQuery()
searchTerm := query.Get("q")
params := router.UseParams()
userID := params.Get("id")
id, ok := params.Int("id")
revalidator := router.UseRevalidator()
revalidator.Revalidate()
layout := router.GetOutlet()
Parent layout routes opt in with router.Options{Layout: true} and render the active child route through router.GetOutlet().
Routes can also define async loaders that provide route-scoped data before rendering the final page component:
r.Register("/users/:id", UserProfile, router.Options{
Loader: func(ctx context.Context, routeCtx router.RouteContext) (router.Attrs, error) {
return router.Attrs{"userID": routeCtx.Params.Get("id")}, nil
},
})
Use RegisterLazy with RouteChunk when route code or a route-owned script must load before the route component and loader run.
Index ¶
- Constants
- func BuildMetadataNode(parseRouterMetadata Metadata) *runtime.Element
- func BuildRouteService() pluginruntime.RouteService
- func DecodeQuery[T any](parseValues url.Values) (T, error)
- func EncodeQuery(parseValue any) url.Values
- func FragmentHref(parseFragment string) string
- func GetCurrentPath() string
- func Href(parsePath string) string
- func Navigate(parsePath string)
- func NavigateReplace(parsePath string)
- func OnNavigate(parseFn func(Location)) func()
- func PreserveReturnTo(parsePath string, parseQuery url.Values) string
- func ReadReturnTo(parseQuery url.Values, parseFallback string) string
- func RegisterElementRoute(parsePath string, parseElemRef js.Value)
- func RegisterLazyRoute(parsePath string, parseComponent interface{}, parseChunk RouteChunk, ...)
- func RegisterRoute(parsePath string, parseComponent interface{}, parseOptions ...Options)
- func RegisteredRoutes() []string
- func RetryLoader(parseKey string) error
- func Revalidate()
- type AsyncGuardFunc
- type AsyncLeaveGuardFunc
- type Attrs
- type Component
- type Element
- type GuardDecision
- type GuardFunc
- type GuardResult
- type LeaveGuardFunc
- type LoaderFunc
- type Location
- type Metadata
- type Navigator
- type Options
- type Params
- type Query
- type Revalidator
- type RouteChunk
- type RouteChunkLoader
- type RouteContext
- type RouteContract
- func (parseC RouteContract) Href(parseParams map[string]string, parseQuery url.Values) (string, error)
- func (parseC RouteContract) HrefFor(parseParams RouteParamsProvider, parseQuery RouteQueryProvider) (string, error)
- func (parseC RouteContract) MustHref(parseParams map[string]string, parseQuery url.Values) string
- func (parseC RouteContract) MustHrefFor(parseParams RouteParamsProvider, parseQuery RouteQueryProvider) string
- func (parseC RouteContract) MustPath(parseParams map[string]string) string
- func (parseC RouteContract) MustPathFor(parseParams RouteParamsProvider) string
- func (parseC RouteContract) ParamNames() []string
- func (parseC RouteContract) Path(parseParams map[string]string) (string, error)
- func (parseC RouteContract) PathFor(parseParams RouteParamsProvider) (string, error)
- func (parseC RouteContract) Pattern() string
- type RouteInspection
- type RouteLoaderInspection
- type RouteParamsProvider
- type RouteQueryProvider
- type RouteRedirectInspection
- type RouteStackInspection
- type Router
- func (parseR *Router) Current() *Element
- func (parseR *Router) GetCurrentPath() string
- func (parseR *Router) GetCurrentRouterPath() stringdeprecated
- func (parseR *Router) GoGetRoute() *Elementdeprecated
- func (parseR *Router) GoRegisterRoute(parsePath string, parseComponent interface{}, parseOptions ...Options)deprecated
- func (parseR *Router) HydrateMount(parseSelector string)
- func (parseR *Router) HydrateMountElement(parseElem js.Value)
- func (parseR *Router) IsLoading() bool
- func (parseR *Router) Mount(parseSelector string)
- func (parseR *Router) MountElement(parseElem js.Value)
- func (parseR *Router) Navigate(parsePath string)
- func (parseR *Router) NavigateReplace(parsePath string)
- func (parseR *Router) Register(parsePath string, parseComponent interface{}, parseOptions ...Options)
- func (parseR *Router) RegisterLazy(parsePath string, parseComponent interface{}, parseChunk RouteChunk, ...)
- func (parseR *Router) RegisteredRoutes() []string
- func (parseR *Router) RetryLoader(parseKey string) error
- func (parseR *Router) Revalidate()
- func (parseR *Router) SetFocusManagement(parseEnabled bool)
- func (parseR *Router) SetViewTransitions(parseEnabled bool)
- type RouterOptions
- type SearchParams
- func (parseS SearchParams) Bool(parseKey string) (bool, bool)
- func (parseS SearchParams) Delete(parseKey string)
- func (parseS SearchParams) Encode() string
- func (parseS SearchParams) Get(parseKey string) string
- func (parseS SearchParams) Has(parseKey string) bool
- func (parseS SearchParams) Int(parseKey string) (int, bool)
- func (parseS SearchParams) Navigate(parseValues url.Values)
- func (parseS SearchParams) Replace(parseKey, parseValue string)
- func (parseS SearchParams) ReplaceAll(parseValues url.Values)
- func (parseS SearchParams) Set(parseKey, parseValue string)
- func (parseS SearchParams) Values() url.Values
Examples ¶
Constants ¶
const (
ReturnToParam = "return_to"
)
Variables ¶
This section is empty.
Functions ¶
func BuildMetadataNode ¶
BuildMetadataNode renders route-managed metadata as SSR-safe head children.
The generated tags are marked so the client router can reconcile and clean up only framework-owned metadata during hydration and later navigations.
func BuildRouteService ¶
func BuildRouteService() pluginruntime.RouteService
BuildRouteService returns one router-backed route service.
func DecodeQuery ¶
DecodeQuery decodes URL query values into a typed struct T using `query:"name"` tags (falling back to the lowercased field name), then validates the result with the validate package using any `validate:"..."` tags on the same struct. It is the typed-search-params path: read `?page=2&sort=desc` into a struct once, with conversion and validation, instead of scattering `q.Get("page")` + manual strconv + bounds checks across the codebase.
Supported field kinds: string, bool, the sized int/uint kinds, float32/64, and []string (for repeated params). A missing param leaves the field at its zero value — mark it `validate:"required"` to reject that. A malformed value (e.g. page=abc for an int) or an unsupported field kind returns an error; validation failures return the validate.Result (which implements error and carries per-field messages).
type ListQuery struct {
Page int `query:"page" validate:"gte=1"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Tags []string `query:"tag"`
}
q, err := router.DecodeQuery[ListQuery](values) // err is a validate.Result on bad input
func EncodeQuery ¶
EncodeQuery renders a typed struct (or a non-nil pointer to one) back into url.Values using the same `query:"name"` tags, skipping zero-valued fields so the resulting URL stays clean. It is the inverse of DecodeQuery, for building links and updating the address bar from typed state. By contract it takes a struct: a non-struct, nil pointer, or other value has no query fields and returns an empty url.Values (it never panics) — DecodeQuery is the validated counterpart, so encoding stays intentionally permissive.
func FragmentHref ¶
FragmentHref returns an in-page anchor href (e.g. a "skip to content" link) that is safe under a <base href> (G7). With a <base href> a bare "#main" resolves against the base (navigating to root); embedding the live path keeps the anchor in-page. It returns "<current-path>#<fragment>".
This targets history routers, where the <base href> footgun exists. Hash routers keep the whole route in the URL fragment, so a second in-page fragment cannot be expressed as an href (use programmatic scrolling instead); to avoid a malformed "#path#fragment", FragmentHref does NOT add the hash-router prefix.
The current query string is preserved (e.g. "/list?page=2#main"), so clicking the anchor stays on the exact current location rather than dropping query state.
A(html.Href(router.FragmentHref("main")), "Skip to content")
func GetCurrentPath ¶
func GetCurrentPath() string
GetCurrentPath returns the current route path from the global router.
func Href ¶
Href returns the correct href attribute value for navigating to path under the active router mode (G7). For a hash router it returns "#<path>"; for a history router it returns the normalized path (which the browser resolves against any <base href>). Use it instead of hand-building href strings so links work regardless of router mode or base href.
A(Href(router.Href("/transactions")), "Transactions")
func Navigate ¶
func Navigate(parsePath string)
Navigate updates the URL using the appropriate method for the current router.
func NavigateReplace ¶
func NavigateReplace(parsePath string)
NavigateReplace replaces the current history entry using the appropriate method for the current router.
func OnNavigate ¶
func OnNavigate(parseFn func(Location)) func()
OnNavigate registers fn to run after each navigation with the new Location — the seam for SPA scroll-reset, analytics page views, and title side effects (G28). It returns an unsubscribe func.
Firing semantics: fn runs once on the initial render (the first location is a change from "none", so analytics see the landing page view), then once per subsequent navigation. It does NOT fire when the location is unchanged (a re-render at the same path+query is deduped). Register before mounting if you need the initial fire.
stop := router.OnNavigate(func(loc router.Location) { scrollTop() })
defer stop()
func PreserveReturnTo ¶
PreserveReturnTo normalizes an internal path plus query values into a bounded return-target payload suitable for auth or re-auth redirects.
func ReadReturnTo ¶
ReadReturnTo reads an internal return-target query value and falls back when the value is empty, oversized, or external.
func RegisterElementRoute ¶
RegisterElementRoute renders a route directly to a DOM element and sets up hash listening.
func RegisterLazyRoute ¶
func RegisterLazyRoute(parsePath string, parseComponent interface{}, parseChunk RouteChunk, parseOptions ...Options)
RegisterLazyRoute registers a route on the global router with a route chunk.
func RegisterRoute ¶
RegisterRoute registers a route with the global router.
func RegisteredRoutes ¶
func RegisteredRoutes() []string
RegisteredRoutes returns a sorted, de-duplicated slice of all registered route path strings from the global router. It delegates to GetRouter().RegisteredRoutes() and returns a non-nil empty slice when no routes are registered or the global router is nil.
func RetryLoader ¶
RetryLoader clears one loader entry by key and re-runs the current route render.
func Revalidate ¶
func Revalidate()
Revalidate clears the current route loader result and runs the route again.
Types ¶
type AsyncGuardFunc ¶
type AsyncGuardFunc func(context.Context, RouteContext) GuardDecision
AsyncGuardFunc decides whether navigation into a route should proceed.
type AsyncLeaveGuardFunc ¶
type AsyncLeaveGuardFunc func(context.Context, RouteContext, RouteContext) GuardDecision
AsyncLeaveGuardFunc decides whether navigation away from a route should proceed.
type Attrs ¶
type Attrs = map[string]interface{}
Component is a type alias for component functions used in routing.
func UseRouteData ¶
func UseRouteData() Attrs
UseRouteData returns loader-provided route data for the current matched route.
type Element ¶
type GuardDecision ¶
GuardDecision describes the outcome of an async navigation guard.
type GuardFunc ¶
type GuardFunc func(RouteContext) GuardResult
GuardFunc decides whether navigation into a route should proceed.
type GuardResult ¶
GuardResult describes the outcome of a navigation guard.
func AllowNavigation ¶
func AllowNavigation() GuardResult
AllowNavigation permits the pending navigation.
func BlockNavigation ¶
func BlockNavigation(parseReason string) GuardResult
BlockNavigation blocks the pending navigation with a reason.
func RedirectNavigation ¶
func RedirectNavigation(parsePath string) GuardResult
RedirectNavigation redirects the pending navigation to path.
type LeaveGuardFunc ¶
type LeaveGuardFunc func(current RouteContext, next RouteContext) GuardResult
LeaveGuardFunc decides whether navigation away from a route should proceed.
type LoaderFunc ¶
type LoaderFunc func(context.Context, RouteContext) (Attrs, error)
type Location ¶
type Location struct {
// Path is the current logical route path (no query string).
Path string
// Query is the encoded query string (without the leading '?').
Query string
// Params are the params captured by the matched route pattern.
Params map[string]string
}
Location is a snapshot of the active route used by the reactive UseRoute / UseLocation hooks (G6). Unlike InspectCurrentRoute (a non-reactive read), a component that calls UseRoute subscribes to navigation and re-renders when the location changes — so memoized chrome (active-nav highlight, breadcrumb) stays in sync without threading the path down as a prop.
func UseLocation ¶
func UseLocation() Location
UseLocation is an alias for UseRoute, matching the naming many router users expect.
func UseRoute ¶
func UseRoute() Location
UseRoute subscribes the calling component to navigation and returns the active Location. When the route changes, every component that called UseRoute re-renders — including memoized chrome — so the active-nav highlight and breadcrumb update without prop-drilling the path (G6).
func Sidebar(_ SidebarProps) ui.Node {
loc := router.UseRoute()
// highlight the link whose href == loc.Path
}
type Metadata ¶
Metadata describes the route-owned metadata currently supported by the router.
These fields are intentionally narrow for the first SSR-aware metadata slice: title, description, and canonical URL. Broader head management remains a separate future concern.
type Navigator ¶
type Navigator struct {
// contains filtered or unexported fields
}
Navigator provides push and replace navigation helpers.
func UseNavigate ¶
func UseNavigate() Navigator
UseNavigate returns a typed navigation handle for the global router.
type Options ¶
type Options struct {
Title string
Redirect string
Description string
CanonicalURL string
Layout bool
Chunk RouteChunk
BeforeEnter GuardFunc
BeforeLeave LeaveGuardFunc
BeforeEnterAsync AsyncGuardFunc
BeforeLeaveAsync AsyncLeaveGuardFunc
GuardPending interface{}
Authorizing interface{}
Loader LoaderFunc
Loading interface{}
Error interface{}
}
Options represents configuration for individual routes. Placeholder for future per-route settings (e.g., titles, guards).
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params provides read-only access to matched route params.
func UseParams ¶
func UseParams() Params
UseParams returns the params captured by the current matched route pattern.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query provides read-only access to parsed query values.
func UseQuery ¶
func UseQuery() Query
UseQuery returns the current URL query values.
For hash routers it reads the `?` portion after the hash path, for example `#/search?q=golang`. For history routers it also supports `window.location.search`.
func (Query) Bool ¶
Bool parses the query value for key as a bool; ok is false when the key is absent or unparseable.
type Revalidator ¶
type Revalidator struct {
// contains filtered or unexported fields
}
Revalidator exposes route-loader revalidation and loading state.
func UseRevalidator ¶
func UseRevalidator() Revalidator
UseRevalidator returns a handle for manually revalidating the current route loader.
func (Revalidator) Loading ¶
func (parseR Revalidator) Loading() bool
Loading reports whether the current route loader is still pending.
func (Revalidator) Revalidate ¶
func (parseR Revalidator) Revalidate()
Revalidate forces the current route loader to run again.
type RouteChunk ¶
type RouteChunk struct {
ID string
Scripts []string
Loader RouteChunkLoader
Loading interface{}
Error interface{}
}
RouteChunk describes a lazy route artifact. Apps can provide Loader for custom wasm/module bootstrapping, or Scripts for the default browser loader.
type RouteChunkLoader ¶
type RouteChunkLoader func(context.Context, RouteContext) error
RouteChunkLoader loads one route-level code artifact before the route factory is invoked.
type RouteContext ¶
RouteContext describes the path, params, and query for a route evaluation.
type RouteContract ¶
type RouteContract struct {
// contains filtered or unexported fields
}
RouteContract stores a validated route pattern together with reverse-routing helpers.
The zero value is NOT valid: Path() and Href() on an uninitialized RouteContract return a "route contract is not initialized" error. Always construct one with DefineRoute (returns an error) or MustDefineRoute (panics on a bad pattern).
func DefineRoute ¶
func DefineRoute(parsePattern string) (RouteContract, error)
DefineRoute validates a route pattern and returns a reusable reverse-routing contract.
Example ¶
ExampleDefineRoute shows declaring a typed route contract, which validates the pattern up front and lets the app build type-safe hrefs for the route.
package main
import (
"github.com/monstercameron/GoWebComponents/v4/router"
)
func main() {
parseUserRoute := router.MustDefineRoute("/users/:id")
// parseUserRoute.Path(...) builds a concrete URL for the :id parameter.
_ = parseUserRoute
}
Output:
func MustDefineRoute ¶
func MustDefineRoute(parsePattern string) RouteContract
MustDefineRoute validates a route pattern and panics if it is invalid.
func (RouteContract) Href ¶
func (parseC RouteContract) Href(parseParams map[string]string, parseQuery url.Values) (string, error)
Href builds a validated navigation target for the contract from raw params and query values.
func (RouteContract) HrefFor ¶
func (parseC RouteContract) HrefFor(parseParams RouteParamsProvider, parseQuery RouteQueryProvider) (string, error)
HrefFor builds a validated navigation target from typed param and query providers.
func (RouteContract) MustHref ¶
MustHref builds a navigation target and panics if params do not satisfy the contract.
func (RouteContract) MustHrefFor ¶
func (parseC RouteContract) MustHrefFor(parseParams RouteParamsProvider, parseQuery RouteQueryProvider) string
MustHrefFor builds a navigation target from typed param and query providers and panics on validation failure.
func (RouteContract) MustPath ¶
func (parseC RouteContract) MustPath(parseParams map[string]string) string
MustPath builds a path and panics if params do not satisfy the contract.
func (RouteContract) MustPathFor ¶
func (parseC RouteContract) MustPathFor(parseParams RouteParamsProvider) string
MustPathFor builds a path from a typed param provider and panics if the contract fails validation.
func (RouteContract) ParamNames ¶
func (parseC RouteContract) ParamNames() []string
ParamNames returns the ordered param names required by the contract.
func (RouteContract) Path ¶
func (parseC RouteContract) Path(parseParams map[string]string) (string, error)
Path builds a validated path for the contract from raw param values.
func (RouteContract) PathFor ¶
func (parseC RouteContract) PathFor(parseParams RouteParamsProvider) (string, error)
PathFor builds a validated path from a typed param provider.
func (RouteContract) Pattern ¶
func (parseC RouteContract) Pattern() string
Pattern returns the normalized route pattern used by the contract.
type RouteInspection ¶
type RouteInspection struct {
Path string
Query url.Values
Params map[string]string
Loading bool
Stack []RouteStackInspection
Loaders []RouteLoaderInspection
LastRedirect RouteRedirectInspection
Metadata Metadata
}
RouteInspection summarizes the currently active route.
func InspectCurrentRoute ¶
func InspectCurrentRoute() RouteInspection
InspectCurrentRoute returns the current path, query, params, and loading state.
type RouteLoaderInspection ¶
type RouteParamsProvider ¶
RouteParamsProvider exposes typed route params for reverse routing helpers.
type RouteQueryProvider ¶
RouteQueryProvider exposes typed query values for reverse routing helpers.
type RouteRedirectInspection ¶
type RouteStackInspection ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router manages routes and navigation for single-page applications.
func NewHashRouter ¶
func NewHashRouter(parseOptions ...RouterOptions) *Router
NewHashRouter creates a hash-based router that reads from window.location.hash.
Example ¶
package main
import (
"github.com/monstercameron/GoWebComponents/v4/html"
"github.com/monstercameron/GoWebComponents/v4/router"
)
func main() {
// Create a new hash-based router
parseR := router.NewHashRouter()
// Define page components
parseHomePage := func(parseProps router.Attrs) *router.Element {
return html.Div(html.Props{}, html.H1(html.Props{}, html.Text("Home")))
}
parseAboutPage := func(parseProps2 router.Attrs) *router.Element {
return html.Div(html.Props{}, html.H1(html.Props{}, html.Text("About")))
}
// Register routes
parseR.GoRegisterRoute("/", parseHomePage)
parseR.GoRegisterRoute("/about", parseAboutPage)
// In a real app, you would mount the router to the DOM
// r.Mount("#app")
}
Output:
func NewHistoryRouter ¶
func NewHistoryRouter(parseOptions ...RouterOptions) *Router
NewHistoryRouter creates a history-based router using the HTML5 History API. This router uses window.location.pathname instead of hash fragments. Requires server to redirect all routes to the app's entry point.
func (*Router) GetCurrentPath ¶
GetCurrentPath returns the current route path from this router instance. It mirrors the package-level GetCurrentPath and is the preferred name over GetCurrentRouterPath.
func (*Router) GetCurrentRouterPath
deprecated
func (*Router) GoGetRoute
deprecated
func (*Router) GoRegisterRoute
deprecated
func (parseR *Router) GoRegisterRoute(parsePath string, parseComponent interface{}, parseOptions ...Options)
GoRegisterRoute registers a route on the router instance.
Deprecated: Use Register instead. GoRegisterRoute exists for compatibility with earlier API consumers and delegates directly to Register.
func (*Router) HydrateMount ¶
HydrateMount binds the router to an already-hydrated DOM target and only wires future route updates/listeners without forcing an immediate rerender.
func (*Router) HydrateMountElement ¶
HydrateMountElement binds the router to an already-hydrated DOM element and only wires future route updates/listeners without forcing an immediate rerender.
func (*Router) Mount ¶
Mount renders the router into a DOM node selected by CSS selector and wires hashchange listeners.
func (*Router) MountElement ¶
MountElement renders the router into an existing DOM element reference.
func (*Router) Navigate ¶
Navigate navigates to a path using the appropriate method for this router type.
func (*Router) NavigateReplace ¶
NavigateReplace replaces the current history entry using the appropriate method for this router type.
func (*Router) Register ¶
func (parseR *Router) Register(parsePath string, parseComponent interface{}, parseOptions ...Options)
Register registers a route using either a component function or a static node.
func (*Router) RegisterLazy ¶
func (parseR *Router) RegisterLazy(parsePath string, parseComponent interface{}, parseChunk RouteChunk, parseOptions ...Options)
RegisterLazy registers a route that loads chunk before rendering component.
func (*Router) RegisteredRoutes ¶
RegisteredRoutes returns a sorted, de-duplicated slice of all registered route path strings for the given Router. Only exact-path routes stored in the routes map are included; catch-all ("*") and dynamic-pattern routes (those stored in patterns) are excluded because they are not discrete navigable paths. A nil receiver returns a non-nil empty slice.
func (*Router) RetryLoader ¶
RetryLoader clears one active loader entry by key and renders the current route again.
func (*Router) Revalidate ¶
func (parseR *Router) Revalidate()
Revalidate clears the cached result for the current route loader and runs it again.
func (*Router) SetFocusManagement ¶
SetFocusManagement enables or disables automatic focus movement to the new route's content after navigation. It is on by default; disable it only if the app manages focus itself.
func (*Router) SetViewTransitions ¶
SetViewTransitions enables or disables the automatic View Transitions animation on navigation. It is on by default; disable it to opt a router out of route-change animation.
type RouterOptions ¶
type RouterOptions struct {
DefaultRoute string
}
RouterOptions configures router defaults.
type SearchParams ¶
type SearchParams struct {
// contains filtered or unexported fields
}
SearchParams provides query values plus navigation helpers that preserve the current path.
func UseSearchParams ¶
func UseSearchParams() SearchParams
UseSearchParams returns the current query values together with update helpers that preserve the active route path while changing the query string.
func (SearchParams) Bool ¶
func (parseS SearchParams) Bool(parseKey string) (bool, bool)
Bool parses the search-param value for key as a bool; ok is false when absent or unparseable.
func (SearchParams) Delete ¶
func (parseS SearchParams) Delete(parseKey string)
Delete pushes a navigation update with key removed.
func (SearchParams) Encode ¶
func (parseS SearchParams) Encode() string
Encode serializes the current search params using net/url encoding.
func (SearchParams) Get ¶
func (parseS SearchParams) Get(parseKey string) string
Get returns the first value for a query key or an empty string.
func (SearchParams) Has ¶
func (parseS SearchParams) Has(parseKey string) bool
Has reports whether a query key is present.
func (SearchParams) Int ¶
func (parseS SearchParams) Int(parseKey string) (int, bool)
Int parses the search-param value for key as an int; ok is false when absent or unparseable.
func (SearchParams) Navigate ¶
func (parseS SearchParams) Navigate(parseValues url.Values)
Navigate applies the provided query values as a pushed navigation update.
func (SearchParams) Replace ¶
func (parseS SearchParams) Replace(parseKey, parseValue string)
Replace updates the current history entry with key assigned to value.
func (SearchParams) ReplaceAll ¶
func (parseS SearchParams) ReplaceAll(parseValues url.Values)
ReplaceAll replaces the current history entry with the provided query values.
func (SearchParams) Set ¶
func (parseS SearchParams) Set(parseKey, parseValue string)
Set pushes a navigation update with key assigned to value.
func (SearchParams) Values ¶
func (parseS SearchParams) Values() url.Values
Values returns a copy of the current search params.