summaryrefslogtreecommitdiff
path: root/gemini/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'gemini/request.go')
-rw-r--r--gemini/request.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/gemini/request.go b/gemini/request.go
index 5220952..51aaae5 100644
--- a/gemini/request.go
+++ b/gemini/request.go
@@ -6,7 +6,7 @@ import (
"io"
"net/url"
- "tildegit.org/tjp/gus"
+ sr "tildegit.org/tjp/sliderule"
)
// InvalidRequestLineEnding indicates that a gemini request didn't end with "\r\n".
@@ -15,7 +15,7 @@ var InvalidRequestLineEnding = errors.New("invalid request line ending")
// ParseRequest parses a single gemini request from a reader.
//
// If the reader argument is a *bufio.Reader, it will only read a single line from it.
-func ParseRequest(rdr io.Reader) (*gus.Request, error) {
+func ParseRequest(rdr io.Reader) (*sr.Request, error) {
bufrdr, ok := rdr.(*bufio.Reader)
if !ok {
bufrdr = bufio.NewReader(rdr)
@@ -39,5 +39,19 @@ func ParseRequest(rdr io.Reader) (*gus.Request, error) {
u.Scheme = "gemini"
}
- return &gus.Request{URL: u}, nil
+ return &sr.Request{URL: u}, nil
+}
+
+// GetTitanRequestBody fetches the request body from a titan request.
+//
+// It returns nil if the argument is not a titan request or it otherwise
+// does not have a request body set.
+func GetTitanRequestBody(request *sr.Request) io.Reader {
+ if request.Scheme != "titan" {
+ return nil
+ }
+ if rdr, ok := request.Meta.(io.Reader); ok {
+ return rdr
+ }
+ return nil
}