Added dummy auth example
This commit is contained in:
+13
-1
@@ -7,6 +7,9 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/twitchtv/twirp"
|
||||
|
||||
"mcquay.me/hwt"
|
||||
pb "mcquay.me/hwt/rpc/hwt"
|
||||
)
|
||||
|
||||
@@ -20,8 +23,17 @@ func main() {
|
||||
|
||||
c := pb.NewHelloWorldProtobufClient(fmt.Sprintf("http://%s", os.Args[1]), &http.Client{})
|
||||
|
||||
h := http.Header{}
|
||||
h.Set("sm-auth", hwt.PSK)
|
||||
ctx := context.Background()
|
||||
ctx, err := twirp.WithHTTPRequestHeaders(ctx, h)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "setting twirp headers: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for i := 0; ; i++ {
|
||||
resp, err := c.Hello(context.Background(), &pb.HelloReq{Subject: strings.Join(os.Args[2:], " ")})
|
||||
resp, err := c.Hello(ctx, &pb.HelloReq{Subject: strings.Join(os.Args[2:], " ")})
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "hello: %#v\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user