MCPcopy Index your code
hub / github.com/SherClockHolmes/webpush-go

github.com/SherClockHolmes/webpush-go @v1.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.4.0 ↗ · + Follow
27 symbols 77 edges 7 files 15 documented · 56% 6 cross-repo links updated 2mo agov1.4.0 · 2025-01-02★ 4443 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

webpush-go

Go Report Card GoDoc

Web Push API Encryption with VAPID support.

go get -u github.com/SherClockHolmes/webpush-go

Example

For a full example, refer to the code in the example directory.

package main

import (
    "encoding/json"

    webpush "github.com/SherClockHolmes/webpush-go"
)

func main() {
    // Decode subscription
    s := &webpush.Subscription{}
    json.Unmarshal([]byte("<YOUR_SUBSCRIPTION>"), s)

    // Send Notification
    resp, err := webpush.SendNotification([]byte("Test"), s, &webpush.Options{
        Subscriber:      "example@example.com",
        VAPIDPublicKey:  "<YOUR_VAPID_PUBLIC_KEY>",
        VAPIDPrivateKey: "<YOUR_VAPID_PRIVATE_KEY>",
        TTL:             30,
    })
    if err != nil {
        // TODO: Handle error
    }
    defer resp.Body.Close()
}

Generating VAPID Keys

Use the helper method GenerateVAPIDKeys to generate the VAPID key pair.

privateKey, publicKey, err := webpush.GenerateVAPIDKeys()
if err != nil {
    // TODO: Handle error
}

Development

  1. Install Go 1.11+
  2. go mod vendor
  3. go test

For other language implementations visit:

WebPush Libs

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 19
Struct 4
Method 2
Interface 1
TypeAlias 1

Languages

Go100%

Modules by API surface

webpush.go10 symbols
webpush_test.go7 symbols
vapid.go4 symbols
vapid_test.go3 symbols
urgency.go2 symbols
example/main.go1 symbols

For agents

$ claude mcp add webpush-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page