Browse Source

Update problem document to closer match rfc

master
Isaac 2 years ago
parent
commit
6f6fb0989c
  1. 24
      problem.go
  2. 14
      problem_test.go

24
problem.go

@ -7,18 +7,22 @@ import (
"net/http"
)
// Problem document as defined in,
// https://tools.ietf.org/html/rfc7807
// Problem represents an error returned by an acme server.
type Problem struct {
Status int `json:"status"`
Type string `json:"type"`
Detail string `json:"detail"`
Instance string `json:"instance"`
SubProblems []struct {
Type string `json:"type"`
Detail string `json:"detail"`
Identifier Identifier
} `json:"subproblems"`
Type string `json:"type"`
Detail string `json:"detail,omitempty"`
Status int `json:"status,omitempty"`
Instance string `json:"instance,omitempty"`
SubProblems []SubProblem `json:"subproblems,omitempty"`
}
type SubProblem struct {
Type string `json:"type"`
Detail string `json:"detail"`
Identifier Identifier `json:"identifier"`
}
// Returns a human readable error string.

14
problem_test.go

@ -48,7 +48,19 @@ func TestCheckError(t *testing.T) {
}
func TestProblem_Error(t *testing.T) {
err := Problem{}
err := Problem{
Status: 123,
Type: "type",
Detail: "detail",
Instance: "instance",
SubProblems: []SubProblem{
{
Type: "type2",
Detail: "detail",
Identifier: Identifier{"DNS", "example.com"},
},
},
}
s := error(err).Error()
if !strings.HasPrefix(s, "acme: error code") {
t.Fatalf("unexpected acme error: %v", err)

Loading…
Cancel
Save