From 629e6a0e0c3a24f35888036f957ee3a631e62816 Mon Sep 17 00:00:00 2001 From: tjp Date: Mon, 13 Nov 2023 07:27:36 -0700 Subject: add nex protocol support --- nex/request.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 nex/request.go (limited to 'nex/request.go') 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 +} -- cgit v1.2.3