routesinfo

package
v0.0.0-...-aeb31df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2016 License: BSD-3-Clause Imports: 4 Imported by: 0

README

RoutesInfo plugin

This plugin collects & stores all registed routes and gives information about them.

The RouteInfo

type RouteInfo struct {
	Method     string
	Domain     string
	Path       string
	RegistedAt time.Time
}

How to use


package main

import (
	"github.com/kataras/iris"
	"github.com/kataras/iris/plugin/routesinfo"
)

func main() {

	info := routesinfo.RoutesInfo()
	iris.Plugin(info)

	iris.Get("/yourpath", func(c *iris.Context) {
		c.Write("yourpath")
	})

	iris.Post("/otherpostpath", func(c *iris.Context) {
		c.Write("other post path")
	})

	all := info.All()
	// allget := info.ByMethod("GET") -> slice
	// alllocalhost := info.ByDomain("localhost") -> slice
	// bypath:= info.ByPath("/yourpath") -> slice
	// bydomainandmethod:= info.ByDomainAndMethod("localhost","GET") -> slice
	// bymethodandpath:= info.ByMethodAndPath("GET","/yourpath") -> single (it could be slice for all domains too but it's not)

	println("The first registed route was: ", all[0].Path, "registed at: ", all[0].RegistedAt.String())
	println("All routes info:")
	for i:= range all {
		println(all[i].String())
		//outputs->
		// Domain: localhost Method: GET Path: /yourpath RegistedAt: 2016/03/27 15:27:05:029 ...
		// Domain: localhost Method: POST Path: /otherpostpath RegistedAt: 2016/03/27 15:27:05:030 ...
	}
	iris.Listen(":8080")

}


Documentation

Index

Constants

This section is empty.

Variables

View Source
var Name = "RoutesInfo"

the name of the plugin

Functions

This section is empty.

Types

type RouteInfo

type RouteInfo struct {
	Method     string
	Domain     string
	Path       string
	RegistedAt time.Time
}

func (RouteInfo) String

func (ri RouteInfo) String() string

type RoutesInfoPlugin

type RoutesInfoPlugin struct {
	// contains filtered or unexported fields
}

func RoutesInfo

func RoutesInfo() *RoutesInfoPlugin

RoutesInfo returns the RoutesInfoPlugin

func (*RoutesInfoPlugin) Activate

func (r *RoutesInfoPlugin) Activate(container iris.IPluginContainer) error

implement the base IPlugin

func (RoutesInfoPlugin) All

func (r RoutesInfoPlugin) All() []RouteInfo

All returns all routeinfos returns a slice

func (RoutesInfoPlugin) ByDomain

func (r RoutesInfoPlugin) ByDomain(domain string) []RouteInfo

ByDomain returns all routeinfos which registed to a specific domain returns a slice, if nothing founds this slice has 0 len&cap

func (RoutesInfoPlugin) ByDomainAndMethod

func (r RoutesInfoPlugin) ByDomainAndMethod(domain string, method string) []RouteInfo

ByDomainAndMethod returns all routeinfos registed to a specific domain and has specific http method returns a slice, if nothing founds this slice has 0 len&cap

func (RoutesInfoPlugin) ByMethod

func (r RoutesInfoPlugin) ByMethod(method string) []RouteInfo

ByMethod returns all routeinfos by a http method returns a slice, if nothing founds this slice has 0 len&cap

func (RoutesInfoPlugin) ByMethodAndPath

func (r RoutesInfoPlugin) ByMethodAndPath(method string, path string) *RouteInfo

ByPathAndMehod returns a single *RouteInfo which has specific http method and path returns only the first match if nothing founds returns nil

func (RoutesInfoPlugin) ByPath

func (r RoutesInfoPlugin) ByPath(path string) []RouteInfo

ByPath returns all routeinfos by a path maybe one path is the same on GET and POST ( for example /login GET, /login POST) because of that it returns a slice and not only one RouteInfo returns a slice, if nothing founds this slice has 0 len&cap

func (RoutesInfoPlugin) GetDescription

func (r RoutesInfoPlugin) GetDescription() string

func (RoutesInfoPlugin) GetName

func (r RoutesInfoPlugin) GetName() string

func (*RoutesInfoPlugin) PostHandle

func (r *RoutesInfoPlugin) PostHandle(route iris.IRoute)

PostHandle collect the registed routes information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL