finish me

This commit is contained in:
Frederick F. Kautz IV
2015-04-26 19:25:48 -07:00
parent d11803b125
commit 9431a54a27
3 changed files with 69 additions and 13 deletions

View File

@@ -17,8 +17,11 @@
package quota
import (
"bytes"
"encoding/binary"
"encoding/xml"
"net"
"net/http"
"sync"
"time"
)
@@ -92,3 +95,24 @@ func (p longIP) IptoUint32() (result uint32) {
}
return binary.BigEndian.Uint32(ip)
}
// copied from api, no cyclic deps allowed
// ErrorResponse - error response format
type ErrorResponse struct {
XMLName xml.Name `xml:"Error" json:"-"`
Code string
Message string
Resource string
RequestID string
HostID string
}
func writeError(w http.ResponseWriter, req *http.Request, errorResponse ErrorResponse, status int) {
var buf bytes.Buffer
encoder := xml.NewEncoder(&buf)
w.WriteHeader(status)
encoder.Encode(errorResponse)
encoder.Flush()
w.Write(buf.Bytes())
}