OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
628 B

package server
import (
"encoding/json"
"net/http"
"github.com/coreos/dex/pkg/log"
)
// writeResponseWithBody attempts to marshal an arbitrary thing to JSON then write
// it to the http.ResponseWriter
func writeResponseWithBody(w http.ResponseWriter, code int, resp interface{}) {
enc, err := json.Marshal(resp)
if err != nil {
log.Errorf("Failed JSON-encoding HTTP response: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
if _, err = w.Write(enc); err != nil {
log.Errorf("Failed writing HTTP response: %v", err)
}
}