Skip to content

Commit

Permalink
docs: add an example using the Go module (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Feb 15, 2021
1 parent f0de6f7 commit dc6a34f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package mercure_test

import (
"log"
"net/http"

"github.com/dunglas/mercure"
)

func Example() {
h, err := mercure.NewHub(
mercure.WithPublisherJWT([]byte("!ChangeMe!"), "HS256"),
mercure.WithSubscriberJWT([]byte("!ChangeMe!"), "HS256"),
)
if err != nil {
log.Fatal(err)
}

http.Handle("/.well-known/mercure", h)
log.Fatal(http.ListenAndServe(":8080", nil))
}
2 changes: 2 additions & 0 deletions hub.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package mercure helps implementing the Mercure protocol (https://mercure.rocks) in Go projects.
// It provides an implementation of a Mercure hub as a HTTP handler.
package mercure

import (
Expand Down

0 comments on commit dc6a34f

Please sign in to comment.