summaryrefslogtreecommitdiff
path: root/nex/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'nex/request.go')
-rw-r--r--nex/request.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/nex/request.go b/nex/request.go
new file mode 100644
index 0000000..290d55d
--- /dev/null
+++ b/nex/request.go
@@ -0,0 +1,28 @@
+package nex
+
+import (
+ "bufio"
+ "io"
+ "net/url"
+ "strings"
+
+ "tildegit.org/tjp/sliderule/internal/types"
+)
+
+// ParseRequest reads a nex request from an io.Reader.
+func ParseRequest(rdr io.Reader) (*types.Request, error) {
+ line, err := bufio.NewReader(rdr).ReadString('\n')
+ if err != nil {
+ return nil, err
+ }
+ line = strings.TrimSuffix(line, "\n")
+ line = strings.TrimSuffix(line, "\r")
+
+ return &types.Request{
+ URL: &url.URL{
+ Scheme: "nex",
+ Path: line,
+ OmitHost: true,
+ },
+ }, nil
+}