diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-08-12 09:40:39 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-08-12 09:40:39 -0600 |
commit | 23bc5f4fb7542e64c94eaa7fe2c7a6aa55010898 (patch) | |
tree | ec8113d3aa2379e3ca9cb3c6e13a5531895ea8c0 /spartan/request.go | |
parent | 57a31a9b2cd549174d839b9b91b47db337f174cc (diff) |
move common types to an internal package
This helps avoid import cycles.
Diffstat (limited to 'spartan/request.go')
-rw-r--r-- | spartan/request.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/spartan/request.go b/spartan/request.go index c056af0..c88a20b 100644 --- a/spartan/request.go +++ b/spartan/request.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/internal/types" ) var ( @@ -23,7 +23,7 @@ var ( // ParseRequest parses a single spartan request and the indicated content-length from a reader. // // If ther reader artument is a *bufio.Reader, it will only read a single line from it. -func ParseRequest(rdr io.Reader) (*sr.Request, int, error) { +func ParseRequest(rdr io.Reader) (*types.Request, int, error) { bufrdr, ok := rdr.(*bufio.Reader) if !ok { bufrdr = bufio.NewReader(rdr) @@ -52,7 +52,7 @@ func ParseRequest(rdr io.Reader) (*sr.Request, int, error) { return nil, 0, err } - return &sr.Request{ + return &types.Request{ URL: &url.URL{ Scheme: "spartan", Host: host, @@ -65,7 +65,7 @@ func ParseRequest(rdr io.Reader) (*sr.Request, int, error) { // GetRequestContentLength reads the remaining un-read number of bytes in a request body. // // It will immediately return 0 if there is no request body. -func GetRequestContentLength(request *sr.Request) int { +func GetRequestContentLength(request *types.Request) int { if lr, ok := request.Meta.(*io.LimitedReader); ok { return int(lr.N) } @@ -75,7 +75,7 @@ func GetRequestContentLength(request *sr.Request) int { // GetRequestBody returns a reader of the spartan request body. // // It will return nil if the request has no body. -func GetRequestBody(request *sr.Request) io.Reader { +func GetRequestBody(request *types.Request) io.Reader { if rdr, ok := request.Meta.(io.Reader); ok { return rdr } @@ -88,7 +88,7 @@ func GetRequestBody(request *sr.Request) io.Reader { // // This function will read the entire contents into memory unless // the reader is already an *io.LimitedReader. -func SetRequestBody(request *sr.Request, body io.Reader) error { +func SetRequestBody(request *types.Request, body io.Reader) error { if rdr, ok := body.(*io.LimitedReader); ok { request.Meta = rdr return nil |