router

package module
v0.0.0-...-9238bd3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-router

修改自 beego router.
出處
https://github.com/astaxie/beego

	// 初始化路由器
	var myRouter router.ControllerRegistor
	// 註冊網頁靜態頁面路徑
	myRouter.SetStaticPath("/", "/html/")

	// 路由器 controller 註冊開始
	myRouter.Add("/", &controllers.IndexController{})

	// 註冊結束 啟動伺服器
	http.HandleFunc("/", myRouter.ServeHTTP)

	open.Run("http://127.0.0.1:8123")
	http.ListenAndServe(":8123", nil)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
}

func (*Controller) Delete

func (c *Controller) Delete(w http.ResponseWriter, r *http.Request)

func (*Controller) Get

func (c *Controller) Get(w http.ResponseWriter, r *http.Request)

func (*Controller) Post

func (c *Controller) Post(w http.ResponseWriter, r *http.Request)

func (*Controller) Put

func (c *Controller) Put(w http.ResponseWriter, r *http.Request)

type ControllerInterface

type ControllerInterface interface {
	Get(w http.ResponseWriter, r *http.Request)
	Post(w http.ResponseWriter, r *http.Request)
	Delete(w http.ResponseWriter, r *http.Request)
	Put(w http.ResponseWriter, r *http.Request)
}

type ControllerRegistor

type ControllerRegistor struct {
	StaticDir map[string]string
	// contains filtered or unexported fields
}

func (*ControllerRegistor) Add

func (p *ControllerRegistor) Add(pattern string, c ControllerInterface)

func (*ControllerRegistor) ServeHTTP

func (p *ControllerRegistor) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ControllerRegistor) SetStaticPath

func (cr *ControllerRegistor) SetStaticPath(url string, path string) *ControllerRegistor

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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