diff options
author | tjp <tjp@ctrl-c.club> | 2023-11-13 07:27:36 -0700 |
---|---|---|
committer | tjp <tjp@ctrl-c.club> | 2023-11-13 07:27:36 -0700 |
commit | 629e6a0e0c3a24f35888036f957ee3a631e62816 (patch) | |
tree | 76001a2311d3566bf0050b3ef2aa3119fe0823bf /nex/request.go | |
parent | 1e0f8e0aaeaf1bd2ee39c02e922238b641bcf88b (diff) |
add nex protocol support
Diffstat (limited to 'nex/request.go')
-rw-r--r-- | nex/request.go | 28 |
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 +} |