Example #1
0
func (r Routes) Apply(router zerver.Router) error {
	for pat, rt := range r {
		if rt.Handler == nil {
			rt.Handler = rt.MapHandler
		}
		err := router.Handler(pat, rt.Handler)
		if err != nil {
			return err
		}
	}
	return nil
}
Example #2
0
func Enable(monitorPath string, rt zerver.Router) (err error) {
	if monitorPath != "" {
		path = monitorPath
	}
	if !initRoutes() {
		return
	}

	for subpath, handler := range routes {
		if err = rt.Handler(path+subpath, handler); err != nil {
			return
		}
		options = append(options, "GET "+path+subpath+": "+infos[subpath]+"\n")
	}
	err = rt.Filter(path, zerver.FilterFunc(globalFilter))
	return
}