Improve SCEP API logic and error handling
This commit is contained in:
parent
30d3a26c20
commit
a191319da9
4 changed files with 145 additions and 103 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/smallstep/certificates/authority/mgmt"
|
||||
"github.com/smallstep/certificates/errs"
|
||||
"github.com/smallstep/certificates/logging"
|
||||
"github.com/smallstep/certificates/scep"
|
||||
)
|
||||
|
||||
// WriteError writes to w a JSON representation of the given error.
|
||||
|
@ -22,6 +23,8 @@ func WriteError(w http.ResponseWriter, err error) {
|
|||
case *mgmt.Error:
|
||||
mgmt.WriteError(w, k)
|
||||
return
|
||||
case *scep.Error:
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
default:
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue