Skip to content

Commit

Permalink
Merge pull request #23 from rogpeppe/025-update-for-jsonhttp-changes
Browse files Browse the repository at this point in the history
fixes for httpjson changes.
  • Loading branch information
rogpeppe committed Oct 30, 2014
2 parents dd2e716 + a1af63a commit 333d5d0
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bakery/discharge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package bakery
import (
"fmt"

"github.com/juju/errgo"
"gopkg.in/errgo.v1"
"gopkg.in/macaroon.v1"
)

Expand Down
2 changes: 1 addition & 1 deletion bakery/example/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"net/url"

"github.com/juju/errgo"
"gopkg.in/errgo.v1"

"github.com/rogpeppe/macaroon/httpbakery"
)
Expand Down
8 changes: 4 additions & 4 deletions bakery/example/idservice/idservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"log"
"net/http"

"github.com/juju/errgo"
"github.com/juju/utils/jsonhttp"
"gopkg.in/errgo.v1"
"gopkg.in/macaroon.v1"

"github.com/rogpeppe/macaroon/bakery"
Expand Down Expand Up @@ -70,7 +70,7 @@ func New(p Params) (http.Handler, error) {

// userHandler handles requests to add new users, change user details, etc.
// It is only accessible to users that are members of the admin group.
func (h *handler) userHandler(w http.ResponseWriter, req *http.Request) (interface{}, error) {
func (h *handler) userHandler(_ http.Header, req *http.Request) (interface{}, error) {
ctxt := h.newContext(req, "change-user")
breq := h.svc.NewRequest(req, ctxt)
err := breq.Check()
Expand Down Expand Up @@ -262,7 +262,7 @@ func (h *handler) needLogin(cavId string, caveat string, why string) error {

// waitHandler serves an HTTP endpoint that waits until a macaroon
// has been discharged, and returns the discharge macaroon.
func (h *handler) waitHandler(w http.ResponseWriter, req *http.Request) (interface{}, error) {
func (h *handler) waitHandler(_ http.Header, req *http.Request) (interface{}, error) {
req.ParseForm()
waitId := req.Form.Get("waitid")
if waitId == "" {
Expand Down Expand Up @@ -297,7 +297,7 @@ func (h *handler) waitHandler(w http.ResponseWriter, req *http.Request) (interfa
}, nil
}

func (h *handler) questionHandler(w http.ResponseWriter, req *http.Request) (interface{}, error) {
func (h *handler) questionHandler(_ http.Header, req *http.Request) (interface{}, error) {
return nil, errgo.New("question unimplemented")
// TODO
// req.ParseForm()
Expand Down
2 changes: 1 addition & 1 deletion bakery/example/idservice/idservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"regexp"
"time"

"github.com/juju/errgo"
gc "gopkg.in/check.v1"
"gopkg.in/errgo.v1"

"github.com/rogpeppe/macaroon/bakery"
"github.com/rogpeppe/macaroon/bakery/example/idservice"
Expand Down
6 changes: 6 additions & 0 deletions dependencies.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
code.google.com/p/go.crypto hg 228579b1f8ccfc93ed9f1709e32e8361ffc9a7ae 229
code.google.com/p/go.net hg c17ad62118ea511e1051721b429779fa40bddc74 116
github.com/juju/utils git 28f1fcf3aec9e481fa9fd7020d0b64c62fb30baf
gopkg.in/check.v1 git f74cd4712c294b0b898bc694214563d14caf3b76
gopkg.in/errgo.v1 git 81357a83344ddd9f7772884874e5622c2a3da21c
gopkg.in/macaroon.v1 git cca9c60024946c02129e3788d997cd00cd5a06ae
2 changes: 1 addition & 1 deletion httpbakery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"

"code.google.com/p/go.net/publicsuffix"
"github.com/juju/errgo"
"gopkg.in/errgo.v1"
"gopkg.in/macaroon.v1"

"github.com/rogpeppe/macaroon/bakery"
Expand Down
20 changes: 6 additions & 14 deletions httpbakery/discharge.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"path"

"github.com/juju/errgo"
"gopkg.in/errgo.v1"
"gopkg.in/macaroon.v1"

"github.com/rogpeppe/macaroon/bakery"
Expand Down Expand Up @@ -85,8 +85,8 @@ type dischargeResponse struct {
Macaroon *macaroon.Macaroon `json:",omitempty"`
}

func (d *dischargeHandler) serveDischarge(w http.ResponseWriter, req *http.Request) (interface{}, error) {
r, err := d.serveDischarge1(w, req)
func (d *dischargeHandler) serveDischarge(h http.Header, req *http.Request) (interface{}, error) {
r, err := d.serveDischarge1(h, req)
if err != nil {
log.Printf("serveDischarge -> error %#v", err)
} else {
Expand All @@ -95,7 +95,7 @@ func (d *dischargeHandler) serveDischarge(w http.ResponseWriter, req *http.Reque
return r, err
}

func (d *dischargeHandler) serveDischarge1(w http.ResponseWriter, req *http.Request) (interface{}, error) {
func (d *dischargeHandler) serveDischarge1(h http.Header, req *http.Request) (interface{}, error) {
log.Printf("dischargeHandler.serveDischarge {")
defer log.Printf("}")
if req.Method != "POST" {
Expand Down Expand Up @@ -124,20 +124,12 @@ func (d *dischargeHandler) serveDischarge1(w http.ResponseWriter, req *http.Requ
return &resp, nil
}

func (d *dischargeHandler) internalError(w http.ResponseWriter, f string, a ...interface{}) {
http.Error(w, fmt.Sprintf(f, a...), http.StatusInternalServerError)
}

func (d *dischargeHandler) badRequest(w http.ResponseWriter, f string, a ...interface{}) {
http.Error(w, fmt.Sprintf(f, a...), http.StatusBadRequest)
}

type thirdPartyCaveatIdRecord struct {
RootKey []byte
Condition string
}

func (d *dischargeHandler) serveCreate(w http.ResponseWriter, req *http.Request) (interface{}, error) {
func (d *dischargeHandler) serveCreate(h http.Header, req *http.Request) (interface{}, error) {
req.ParseForm()
condition := req.Form.Get("condition")
rootKeyStr := req.Form.Get("root-key")
Expand Down Expand Up @@ -174,7 +166,7 @@ func (d *dischargeHandler) serveCreate(w http.ResponseWriter, req *http.Request)
}, nil
}

func (d *dischargeHandler) servePublicKey(w http.ResponseWriter, r *http.Request) (interface{}, error) {
func (d *dischargeHandler) servePublicKey(h http.Header, r *http.Request) (interface{}, error) {
return nil, fmt.Errorf("not implemented yet")
}

Expand Down
2 changes: 1 addition & 1 deletion httpbakery/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package httpbakery
import (
"net/http"

"github.com/juju/errgo"
"github.com/juju/utils/jsonhttp"
"gopkg.in/errgo.v1"
"gopkg.in/macaroon.v1"
)

Expand Down

0 comments on commit 333d5d0

Please sign in to comment.