door

package module
v0.0.0-...-057aa67 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2017 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ws-door

websocket router.

Documentation

Overview

Package door is a generated protocol buffer package.

It is generated from these files:

event.proto

It has these top-level messages:

Event

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotFound = errors.New("Not found")

ErrorNotFound 没找到错误.

View Source
var MethodEnum_name = map[int32]string{
	0: "OPEN",
	1: "CLOSE",
	2: "GET",
	3: "POST",
	4: "PUT",
	5: "DELETE",
}
View Source
var MethodEnum_value = map[string]int32{
	"OPEN":   0,
	"CLOSE":  1,
	"GET":    2,
	"POST":   3,
	"PUT":    4,
	"DELETE": 5,
}
View Source
var NotFoundHandler = func(c Context) error {
	return ErrorNotFound
}

NotFoundHandler 没找到.

Functions

This section is empty.

Types

type Context

type Context struct {
	Method MethodEnum
	// contains filtered or unexported fields
}

Context 内容.

func (*Context) DelAttribut

func (context *Context) DelAttribut(key string)

DelAttribut 删除属性.

func (*Context) Execute

func (context *Context) Execute(path string) error

Execute 执行过滤器.

func (*Context) GetAttribute

func (context *Context) GetAttribute(key string) (value interface{}, ok bool)

GetAttribute 获取属性.

func (*Context) Marshal

func (context *Context) Marshal(pb proto.Message) (err error)

Marshal 编码proto.

func (*Context) Next

func (context *Context) Next() error

Next 下一个过滤器

func (*Context) Num

func (context *Context) Num() uint32

Num 当前Context的编号.

func (*Context) Numbers

func (context *Context) Numbers() (nums []uint32)

Numbers 全部客户端编号.

func (*Context) Pass

func (context *Context) Pass() bool

Pass 是否通过过滤器.

func (*Context) PutAttribute

func (context *Context) PutAttribute(key string, value interface{})

PutAttribute 设置属性.

func (*Context) Revert

func (context *Context) Revert(pb proto.Message, method MethodEnum, paths ...string) error

Revert 回复.

func (*Context) Send

func (context *Context) Send(num uint32, pb proto.Message, method MethodEnum, paths ...string) error

Send 发送对象.

func (*Context) Unmarshal

func (context *Context) Unmarshal(pb proto.Message) error

Unmarshal 解码proto.

type Door

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

Door is golang websocket router.

func New

func New() *Door

New Door.

func (*Door) AddFilter

func (door *Door) AddFilter(filter Executer, paths ...string)

AddFilter 增加过滤器.

func (*Door) CLOSE

func (door *Door) CLOSE(h HandlerFunc, paths ...string)

CLOSE 设置关闭功能.

func (*Door) Close

func (door *Door) Close(num uint32)

Close connect by num.

func (*Door) DELETE

func (door *Door) DELETE(h HandlerFunc, paths ...string)

DELETE 设置删除功能.

func (*Door) GET

func (door *Door) GET(h HandlerFunc, paths ...string)

GET 设置获取功能.

func (*Door) OPEN

func (door *Door) OPEN(h HandlerFunc, paths ...string)

OPEN 设置开启功能.

func (*Door) POST

func (door *Door) POST(h HandlerFunc, paths ...string)

POST 设置增加功能.

func (*Door) PUT

func (door *Door) PUT(h HandlerFunc, paths ...string)

PUT 设置修改功能.

func (*Door) WebsocketHandler

func (door *Door) WebsocketHandler(w http.ResponseWriter, r *http.Request) error

WebsocketHandler Websocket handler.

type ErrorNotNum

type ErrorNotNum struct {
	Num uint32
}

ErrorNotNum 编号错误.

func (ErrorNotNum) Error

func (errorNotNum ErrorNotNum) Error() string

type Event

type Event struct {
	Path   string     `protobuf:"bytes,1,opt,name=path" json:"path,omitempty"`
	Method MethodEnum `protobuf:"varint,2,opt,name=method,enum=door.MethodEnum" json:"method,omitempty"`
	Data   []byte     `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
}

func (*Event) Descriptor

func (*Event) Descriptor() ([]byte, []int)

func (*Event) GetData

func (m *Event) GetData() []byte

func (*Event) GetMethod

func (m *Event) GetMethod() MethodEnum

func (*Event) GetPath

func (m *Event) GetPath() string

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) Reset

func (m *Event) Reset()

func (*Event) String

func (m *Event) String() string

type Executer

type Executer interface {
	Execute(*Context) error
}

Executer 过滤器接口.

type Filter

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

Filter 过滤器.

type HandlerFunc

type HandlerFunc func(Context) error

HandlerFunc 定义 websocket 请求.

type Inline

type Inline struct {
	Handler func(*Context) error
}

Inline 是单行过滤器.

func (*Inline) Execute

func (filter *Inline) Execute(context *Context) error

Execute runs the inlined handler.

type MethodEnum

type MethodEnum int32
const (
	MethodEnum_OPEN   MethodEnum = 0
	MethodEnum_CLOSE  MethodEnum = 1
	MethodEnum_GET    MethodEnum = 2
	MethodEnum_POST   MethodEnum = 3
	MethodEnum_PUT    MethodEnum = 4
	MethodEnum_DELETE MethodEnum = 5
)

func (MethodEnum) EnumDescriptor

func (MethodEnum) EnumDescriptor() ([]byte, []int)

func (MethodEnum) String

func (x MethodEnum) String() string

type Router

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

Router 路由器.

func NewRouter

func NewRouter() *Router

NewRouter 新建路由器.

func (*Router) Add

func (router *Router) Add(h HandlerFunc, method MethodEnum, paths ...string)

Add 增加路由.

func (*Router) Find

func (router *Router) Find(method MethodEnum, paths ...string) HandlerFunc

Find 路由查找.

func (*Router) Finds

func (router *Router) Finds(method MethodEnum) []HandlerFunc

Finds 路由全部查找.

Directories

Path Synopsis
chat
Package chat is a generated protocol buffer package.
Package chat is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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