Documentation
¶
Index ¶
- func NewHandler(vey vey.Vey, sender email.Sender, open *url.URL) http.Handler
- func Wrap(h Handler) http.Handler
- func WrapF(f func(http.ResponseWriter, *http.Request) error) http.Handler
- func WriteJSON(w http.ResponseWriter, statusCode int, out interface{}) error
- type Body
- type BodyFunc
- type Client
- func (c Client) BeginDelete(email string, publicKey vey.PublicKey) error
- func (c Client) BeginPut(email string, publicKey vey.PublicKey) error
- func (c Client) CommitDelete(token []byte) error
- func (c Client) CommitPut(challenge, signature []byte) error
- func (c Client) Do(path string, body Body) (*http.Response, error)
- func (c Client) Get(path string, q url.Values) (*http.Response, error)
- func (c Client) GetKeys(email string) ([]vey.PublicKey, error)
- func (c Client) Open(query url.Values) (string, error)
- type ClientError
- type Error
- type Handler
- type HandlerFunc
- type Logger
- type VeyHandler
- func (h *VeyHandler) BeginDelete(w http.ResponseWriter, r *http.Request, b Body) error
- func (h *VeyHandler) BeginPut(w http.ResponseWriter, r *http.Request, b Body) error
- func (h *VeyHandler) CommitDelete(w http.ResponseWriter, r *http.Request) error
- func (h *VeyHandler) CommitPut(w http.ResponseWriter, r *http.Request, b Body) error
- func (h *VeyHandler) GetKeys(w http.ResponseWriter, r *http.Request, b Body) error
- func (h *VeyHandler) Open(w http.ResponseWriter, r *http.Request) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client is a HTTP client that consumes Vey's HTTP APIs.
func NewClient ¶
NewClient creates a new HTTP client that consumes Vey's HTTP APIs, given a root URL.
func (Client) BeginDelete ¶
BeginDelete calls the BeginDelete interface on the Vey server.
func (Client) CommitDelete ¶
CommitDelete calls the CommitDelete interface on the Vey server.
func (Client) Do ¶
Do does request preparation and error handling common to all of Vey's HTTP APIs. Caller should Close the response.Body when error is nil.
type ClientError ¶
type ClientError struct {
Msg string // Error message
Res *http.Response // The *http.Response returned from http.Client if it was returned from http.Client
Err error // underlying error if any
}
func (ClientError) Error ¶
func (e ClientError) Error() string
ClientError implements error interface.
func (ClientError) Unwrap ¶
func (e ClientError) Unwrap() error
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request) error
func AcceptJSON ¶
func AcceptJSON(h BodyFunc) HandlerFunc
AcceptJSON parses the request body into Body struct. Be careful that, the request body is EOF when later trying to read it again. AcceptJSON responds and doesn't call h, if JSON decoding to Body struct fails.
func (HandlerFunc) ServeHTTP ¶
func (h HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) error
type Logger ¶
type Logger interface {
// Error logs an error.
// err can be of type Error and unwrapped to return the underlying error.
Error(err error)
}
Logger logs errors.
type VeyHandler ¶
func (*VeyHandler) BeginDelete ¶
func (h *VeyHandler) BeginDelete(w http.ResponseWriter, r *http.Request, b Body) error
func (*VeyHandler) BeginPut ¶
func (h *VeyHandler) BeginPut(w http.ResponseWriter, r *http.Request, b Body) error
func (*VeyHandler) CommitDelete ¶
func (h *VeyHandler) CommitDelete(w http.ResponseWriter, r *http.Request) error
CommitDelete handles the final step of deleting the public key. The user receives the URL to CommitDelete in the email and opens it in their browser. token parameter should be in query.
func (*VeyHandler) CommitPut ¶
func (h *VeyHandler) CommitPut(w http.ResponseWriter, r *http.Request, b Body) error
func (*VeyHandler) GetKeys ¶
func (h *VeyHandler) GetKeys(w http.ResponseWriter, r *http.Request, b Body) error
func (*VeyHandler) Open ¶
func (h *VeyHandler) Open(w http.ResponseWriter, r *http.Request) error