core

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventComponentVerifyTicket    = "component_verify_ticket"
	EventAuthorized               = "authorized"
	EventUpdateAuthorized         = "updateauthorized"
	EventUnauthorized             = "unauthorized"
	EventNotifyThirdFasteregister = "notify_third_fasteregister"
)
View Source
const (
	AutoTestMpId = "wxd101a85aa106f53e"
)
View Source
const (
	ComponentTicketCacheKeyPrefix = "CACHE_TICKET@@"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CDATAText

type CDATAText struct {
	Text string `xml:",innerxml"`
}

type Cache

type Cache interface {
	Set(key string, val interface{}) error
	SetEx(key string, val interface{}, expires int64) error
	Get(key string) ([]byte, error)
	Exists(key string) bool
}

Cache

type CacheConfig

type CacheConfig struct {
	MaxIdle     int
	MaxActive   int
	IdleTimeout time.Duration
	Host        string
	Auth        string
}

CacheConfig

type CacheDefault

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

func NewCache

func NewCache(config *CacheConfig) *CacheDefault

func (*CacheDefault) Exists

func (self *CacheDefault) Exists(key string) bool

func (*CacheDefault) Get

func (self *CacheDefault) Get(key string) (reply []byte, err error)

func (*CacheDefault) Set

func (self *CacheDefault) Set(key string, val interface{}) error

func (*CacheDefault) SetEx

func (self *CacheDefault) SetEx(key string, val interface{}, expires int64) error

type CipherRequestHttpBody

type CipherRequestHttpBody struct {
	XMLName            xml.Name `xml:"xml"`
	AppId              string   `xml:"AppId"`
	Base64EncryptedMsg []byte   `xml:"Encrypt"`
}

type CipherResponseHttpBody

type CipherResponseHttpBody struct {
	XMLName      xml.Name `xml:"xml"`
	Encrypt      string   `xml:"Encrypt"`
	MsgSignature string   `xml:"MsgSignature"`
	TimeStamp    string   `xml:"TimeStamp"`
	Nonce        string   `xml:"Nonce"`
}

type ClientConfig

type ClientConfig struct {
	AppId     string
	AppSecret string
	Token     string
	AesKey    string
	BaseUrl   string
}

type Endpoint

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

func NewEndpoint

func NewEndpoint(base string) *Endpoint

func (*Endpoint) ApiAuthorizerToken

func (self *Endpoint) ApiAuthorizerToken(componentToken string) string

func (*Endpoint) ApiQueryAuth

func (self *Endpoint) ApiQueryAuth(componentToken string) string

func (*Endpoint) CommitCode

func (self *Endpoint) CommitCode(componentToken string) string

func (*Endpoint) ComponentAccessTokenUrl

func (self *Endpoint) ComponentAccessTokenUrl() string

func (*Endpoint) CustomService

func (self *Endpoint) CustomService(componentToken string) string

func (*Endpoint) FastRegisterWeapp

func (self *Endpoint) FastRegisterWeapp(componentToken string) string

func (*Endpoint) ModifyDomain

func (self *Endpoint) ModifyDomain(componentToken string) string

func (*Endpoint) PreAuthCodoUrl

func (self *Endpoint) PreAuthCodoUrl(componentToken string) string

func (*Endpoint) Release

func (self *Endpoint) Release(componentToken string) string

func (*Endpoint) SetBaseUrl

func (self *Endpoint) SetBaseUrl(base string)

type EventHeaderMessage

type EventHeaderMessage struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   string   `xml:"ToUserName"`
	FromUserName string   `xml:"FromUserName"`
	CreateTime   int64    `xml:"CreateTime"`
	MsgType      string   `xml:"MsgType"`
}

type EventMessage

type EventMessage struct {
	EventHeaderMessage
	MsgId   int64  `xml:"MsgId"`
	Content string `xml:"Content"`
}

type HttpClient

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

func NewHttpClient

func NewHttpClient() *HttpClient

func (*HttpClient) Get

func (self *HttpClient) Get(url string) (status int, body []byte, err error)

func (*HttpClient) Post

func (self *HttpClient) Post(url, contentType string, data []byte) (status int, body []byte, err error)

func (*HttpClient) ReadXML

func (self *HttpClient) ReadXML(r *http.Request) []byte

type IClient

type IClient interface {
	GetToken() (map[string]interface{}, error)
	RefreshToken() (map[string]interface{}, error)
}

type Message

type Message interface {
	NewTextMessage(w *http.ResponseWriter, text *Text) ([]byte, error)
}

type MessageDecoder

type MessageDecoder struct {
	Signature    string
	Timestamp    string
	Nonce        string
	MsgSignature string
	Random       []byte
	EncryptMsg   []byte
}

func (*MessageDecoder) DecodeComponentVerifyTicket

func (self *MessageDecoder) DecodeComponentVerifyTicket(appId, aesKey string) (NotifyMessage, error)

func (*MessageDecoder) DecodeEventMessage

func (self *MessageDecoder) DecodeEventMessage(appId, aesKey string) (EventMessage, error)

func (*MessageDecoder) VerifySignature

func (self *MessageDecoder) VerifySignature(token string) bool

type MessageEncoder

type MessageEncoder struct {
	Signature string
	Timestamp string
	Nonce     string
	Random    []byte
	RawMsg    []byte
}

func (*MessageEncoder) EncodeMessage

func (self *MessageEncoder) EncodeMessage(appId, token, aesKey string) (string, error)

type MessageHeader

type MessageHeader struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   string   `xml:"ToUserName"`
	FromUserName string   `xml:"FromUserName"`
	CreateTime   int64    `xml:"CreateTime"`
	MsgType      string   `xml:"MsgType"`
}

type NotifyHeaderMessage

type NotifyHeaderMessage struct {
	XMLName    xml.Name `xml:"xml"`
	AppId      string   `xml:"AppId"`
	CreateTime int64    `xml:"CreateTime"`
	InfoType   string   `xml:"InfoType"`
}

type NotifyMessage

type NotifyMessage struct {
	NotifyHeaderMessage
	ComponentVerifyTicket string `xml:"ComponentVerifyTicket"`
}

type Server

type Server struct {
	Cache     Cache
	AppId     string
	AppSecret string
	Token     string
	AesKey    string
}

func NewServer

func NewServer(clientConfig *ClientConfig, cache Cache) *Server

func (*Server) EventServe

func (self *Server) EventServe(w http.ResponseWriter, r *http.Request)

func (*Server) NewTextMessage

func (self *Server) NewTextMessage(w http.ResponseWriter, text *Text) ([]byte, error)

func (*Server) ReadXML

func (self *Server) ReadXML(r *http.Request) []byte

func (*Server) Serve

func (self *Server) Serve(w http.ResponseWriter, r *http.Request)

Serve 处理事件推送

type Text

type Text struct {
	MessageHeader
	Content string `xml:"Content"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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