Documentation ¶
Overview ¶
Package chirouter is an Ambient plugin for a router using go-chi/chi.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin represents an Ambient plugin.
func New ¶
func New(serveHTTP ambient.CustomServeHTTP) *Plugin
New returns an Ambient plugin for a router using a variation of the way router. A custom CustomServeHTTP can be passed in to override how errors are handled.
Example ¶
package main import ( "log" "github.com/ambientkit/ambient" "github.com/ambientkit/ambient/pkg/ambientapp" "github.com/ambientkit/plugin/logger/zaplogger" "github.com/ambientkit/plugin/router/chirouter" "github.com/ambientkit/plugin/storage/memorystorage" ) func main() { plugins := &ambient.PluginLoader{ // Core plugins are implicitly trusted. Router: chirouter.New(nil), TemplateEngine: nil, SessionManager: nil, // Trusted plugins are those that are typically needed to boot so they // will be enabled and given full access. TrustedPlugins: map[string]bool{}, Plugins: []ambient.Plugin{}, Middleware: []ambient.MiddlewarePlugin{ // Middleware - executes top to bottom. }, } _, _, err := ambientapp.NewApp("myapp", "1.0", zaplogger.New(), ambient.StoragePluginGroup{ Storage: memorystorage.New(), }, plugins) if err != nil { log.Fatalln(err.Error()) } }
Output:
func (*Plugin) PluginName ¶
PluginName returns the plugin name.
func (*Plugin) PluginVersion ¶
PluginVersion returns the plugin version.
Click to show internal directories.
Click to hide internal directories.