Skip to content

Commit

Permalink
Merge 5055066 into 0592f0b
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Buliński committed Aug 9, 2018
2 parents 0592f0b + 5055066 commit 2a02d86
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package main

import (
"fmt"
"time"
"github.com/hiyosi/hawk"
"net/http"
)
Expand All @@ -40,9 +41,9 @@ func (c *credentialStore) GetCredential(id string) (*hawk.Credential, error) {
var testCredStore = &credentialStore{}

func hawkHandler(w http.ResponseWriter, r *http.Request) {
s := hawk.NewServer(testCredStore)
s := hawk.NewServer(testCredStore)

// authenticate client request
// authenticate client request
cred, err := s.Authenticate(r)
if err != nil {
w.Header().Set("WWW-Authenticate", "Hawk")
Expand All @@ -64,7 +65,6 @@ func hawkHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, " + cred.ID))
}


func main() {
http.HandleFunc("/resource", hawkHandler)
http.ListenAndServe(":8080", nil)
Expand All @@ -77,14 +77,14 @@ package main

import (
"fmt"
"time"
"github.com/hiyosi/hawk"
"io/ioutil"
"net/http"
"time"
)

func main() {
c := hqwk.NewClient(
c := hawk.NewClient(
&hawk.Credential{
ID: "123456",
Key: "werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn",
Expand All @@ -97,7 +97,7 @@ func main() {
},
)

// build request header
// build request header
header, _ := c.Header("GET", "http://localhost:8080/resource")
req, _ := http.NewRequest("GET", "http://localhost:8080/resource", nil)
req.Header.Set("Authorization", header)
Expand All @@ -111,7 +111,7 @@ func main() {
}
defer resp.Body.Close()

// authenticate server response.
// authenticate server response.
result, err := c.Authenticate(resp)
if err != nil {
fmt.Println("Server Authentication Failure")
Expand All @@ -123,7 +123,6 @@ func main() {
fmt.Println(string(b))
}
}

```

***build bewit parameter***
Expand Down

0 comments on commit 2a02d86

Please sign in to comment.