webpush

package
v0.0.0-...-d560322 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gcm implements communication between master and slave for WebPush.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadVAPIDKey

func LoadVAPIDKey(filename string) ([]byte, error)

Types

type Credential

type Credential struct {
	// VAPID
	VAPID *VAPID
	// (テスト用)サーバ証明書の正当性を確認をしない
	InsecureSkipVerify bool
}

CredentialはWebPushサーバにアクセスする資格情報をあらわす。

type FailedMessage

type FailedMessage struct {
	// WebPushとは関係のない場所で発生したエラー(例えば"no such host")
	ErrorString string
	// WebPushプロトコルにおけるエラーの場合にセット
	Detail *ProtocolError
	// リクエストしたメッセージ
	Message *Message
}

FailedMessageは送信失敗したメッセージとその理由をあらわす。 必ず、ErrorString、Detailはどれか1つだけセットされる。 なのでDetailを判定し、nilならErrorStringをエラーの理由として扱うこと。

type Message

type Message struct {
	Token      *Token
	Payload    string
	TimeToLive int // in second
	Urgency    Urgency
	Topic      string // like FCM's collapse_key
}

type ProtocolError

type ProtocolError struct {
	StatusCode int
}

func (*ProtocolError) InvalidToken

func (e *ProtocolError) InvalidToken() bool

type Request

type Request struct {
	Credential *Credential
	Messages   []*Message
	BandWidth  int32 // 1秒あたりの通知数(0以下なら無制限)
}

type Response

type Response struct {
	// 送信失敗したメッセージと理由。
	// すべて成功した場合は空の配列。
	FailedMessages []*FailedMessage
}

Responseはリクエストに対するスレーブからの応答をあらわす。

type Token

type Token struct {
	Version   int    `json:"v"`
	URL       string `json:"endpoint"`
	PublicKey string `json:"p256dh"`
	AuthToken string `json:"auth"`
}

Token represents BoltzEngine specific WebPush token.

func (*Token) String

func (token *Token) String() (string, error)

type Urgency

type Urgency int
const (
	VeryLow Urgency = iota
	Low
	Normal
	High
)

type VAPID

type VAPID struct {
	Subject    string // トークン生成者のURI(mailto: or https:)
	PublicKey  []byte
	PrivateKey []byte
}

VAPID represents Voluntary Application Server Identification for Web Push.

Jump to

Keyboard shortcuts

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