router

package
v0.0.0-...-417840b Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2013 Julien Schmidt. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Modified by povsister

Copyright 2013 Julien Schmidt. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Modified by povsister

Index

Constants

View Source
const (
	// 群聊或者私聊消息
	Message callbackType = "message"
	// 各种事件
	Event callbackType = "event"
	// 邀请加群请求 或者
	Request callbackType = "request"
)

Variables

View Source
var (
	Router      *router
	NoopHandler Handle = func(bot *bot.Bot, msg interface{}, ps Params) {}
)

Functions

func NewRouter

func NewRouter() *router

Types

type Handle

type Handle func(bot *bot.Bot, msg interface{}, ps Params)

type Param

type Param struct {
	Key   string
	Value string
}

Param is a single URL parameter, consisting of a key and a value.

type Params

type Params []Param

Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.

func (Params) ByName

func (ps Params) ByName(name string) string

ByName returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.

Jump to

Keyboard shortcuts

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