diff options
Diffstat (limited to 'spartan/response.go')
-rw-r--r-- | spartan/response.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/spartan/response.go b/spartan/response.go index bd906e0..aeddd68 100644 --- a/spartan/response.go +++ b/spartan/response.go @@ -8,20 +8,20 @@ import ( "strconv" "sync" - "tildegit.org/tjp/gus" + sr "tildegit.org/tjp/sliderule" ) // The spartan response types. const ( - StatusSuccess gus.Status = 2 - StatusRedirect gus.Status = 3 - StatusClientError gus.Status = 4 - StatusServerError gus.Status = 5 + StatusSuccess sr.Status = 2 + StatusRedirect sr.Status = 3 + StatusClientError sr.Status = 4 + StatusServerError sr.Status = 5 ) // Success builds a successful spartan response. -func Success(mediatype string, body io.Reader) *gus.Response { - return &gus.Response{ +func Success(mediatype string, body io.Reader) *sr.Response { + return &sr.Response{ Status: StatusSuccess, Meta: mediatype, Body: body, @@ -29,24 +29,24 @@ func Success(mediatype string, body io.Reader) *gus.Response { } // Redirect builds a spartan redirect response. -func Redirect(url string) *gus.Response { - return &gus.Response{ +func Redirect(url string) *sr.Response { + return &sr.Response{ Status: StatusRedirect, Meta: url, } } // ClientError builds a "client error" spartan response. -func ClientError(err error) *gus.Response { - return &gus.Response{ +func ClientError(err error) *sr.Response { + return &sr.Response{ Status: StatusClientError, Meta: err.Error(), } } // ServerError builds a "server error" spartan response. -func ServerError(err error) *gus.Response { - return &gus.Response{ +func ServerError(err error) *sr.Response { + return &sr.Response{ Status: StatusServerError, Meta: err.Error(), } @@ -58,7 +58,7 @@ var InvalidResponseHeaderLine = errors.New("Invalid response header line.") // InvalidResponseLineEnding indicates that a spartan response header didn't end with "\r\n". var InvalidResponseLineEnding = errors.New("Invalid response line ending.") -func ParseResponse(rdr io.Reader) (*gus.Response, error) { +func ParseResponse(rdr io.Reader) (*sr.Response, error) { bufrdr := bufio.NewReader(rdr) hdrLine, err := bufrdr.ReadString('\n') @@ -74,15 +74,15 @@ func ParseResponse(rdr io.Reader) (*gus.Response, error) { return nil, InvalidResponseHeaderLine } - return &gus.Response{ - Status: gus.Status(status), + return &sr.Response{ + Status: sr.Status(status), Meta: hdrLine[2 : len(hdrLine)-2], Body: bufrdr, }, nil } // NewResponseReader builds a reader for a response. -func NewResponseReader(response *gus.Response) gus.ResponseReader { +func NewResponseReader(response *sr.Response) sr.ResponseReader { return &responseReader{ Response: response, once: &sync.Once{}, @@ -90,7 +90,7 @@ func NewResponseReader(response *gus.Response) gus.ResponseReader { } type responseReader struct { - *gus.Response + *sr.Response reader io.Reader once *sync.Once } |