router

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: MIT Imports: 3 Imported by: 2

README

Router 路由接口

网页url地址解析的路由接口

可用路由实现

路由参数

//获取路由参数
params:=router.GetParams(r)

//设置路由参数 params.Set("paramname","value")

//获取路由参数 v=parans.Get("paramname")

Documentation

Index

Constants

View Source
const ContextNameRouterParams = ContextName("routerParams")

ContextNameRouterParams router params context name

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextName

type ContextName string

ContextName context name type

type Param

type Param struct {
	Name  string
	Value string
}

Param router param. Param should be parsed from url by router.

type Params

type Params []Param

Params params collection.

func GetParams

func GetParams(r *http.Request) *Params

GetParams get params from http request. If params collection does not exist,new param collection will be create and add to request.

func (*Params) Get

func (p *Params) Get(name string) string

Get get param value by name.

func (*Params) Set

func (p *Params) Set(name string, value string)

Set get param value by name.

type Router

type Router interface {
	//ServeHTTP serve as http handler
	ServeHTTP(w http.ResponseWriter, r *http.Request)
	//StripPrefix strip request prefix and server as a middleware app
	StripPrefix(path string) *middleware.App
}

Router router interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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