A router for client-side web applications written in go which compiles to javascript via gopherjs.
This version includes an improvement to the regex used for route pattern matching and support for query parameters.
This version is backwards compatible with version 0.4.0.
Big thanks to @jancona for contributing!
Context.QueryParameters
.This version includes small bug fixes and minor new features.
InterceptLinks
was not working in some cases when multiple links were present on the page. (Thanks @boyvinall!)log.Fatal
if a path did not match any known routes. This was causing Karma tests to fail and may have been causing some issues in real world usage.Verbose
option, which if set to true
will cause a router to log whenever a path does not match any known routes. This can be viewed as a replacement for the old log.Fatal
behavior.This release simply fixes some typos in the README.
This release fixes one minor bug and makes handler functions more flexible.
In previous releases, router.Handler
was a function that accepted a map[string]string
as an argument. Version 0.2.0 changes that, instead using router.Context
as an argument, which is defined as follows:
// Context is used as an argument to Handlers
type Context struct {
// Params is the parameters from the url as a map of names to values.
Params map[string]string
// Path is the path that triggered this particular route. If the hash
// fallback is being used, the value of path does not include the '#'
// symbol.
Path string
// InitialLoad is true iff this route was triggered during the initial
// page load. I.e. it is true if this is the first path that the browser
// was visiting when the javascript finished loading.
InitialLoad bool
}
In addition, this release fixes a minor bug. In previous releases, a router behaved differently depending on whether or not history.pushState was supported. If the router was using the hash fallback, it would trigger a route during the initial page load. However, if the pushState implementation was being used, it would not do so. Version 0.2.0 unifies the two implementations, and now they will both trigger the appropriate route on initial page load. We have also included Context.InitialLoad
, which is a boolean indicating whether or not the route was triggered on initial page load.
Context
as an argument instead of a map of parameters.This is the initial release following the migration from github.com/soroushjp to github.com/go-humble and the split into stand-alone packages.
See the README for a list of features, a getting started guide, and more information.