summaryrefslogtreecommitdiff
path: root/gopher/protocol.go
diff options
context:
space:
mode:
Diffstat (limited to 'gopher/protocol.go')
-rw-r--r--gopher/protocol.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/gopher/protocol.go b/gopher/protocol.go
new file mode 100644
index 0000000..22ccd56
--- /dev/null
+++ b/gopher/protocol.go
@@ -0,0 +1,27 @@
+package gopher
+
+import (
+ "io"
+ "net/url"
+
+ "tildegit.org/tjp/sliderule/internal/types"
+)
+
+type proto struct{}
+
+func (p proto) TemporaryRedirect(u *url.URL) *types.Response { return nil }
+func (p proto) PermanentRedirect(u *url.URL) *types.Response { return nil }
+
+func (p proto) TemporaryServerError(err error) *types.Response { return Error(err).Response() }
+func (p proto) PermanentServerError(err error) *types.Response { return Error(err).Response() }
+func (p proto) CGIFailure(err error) *types.Response { return Error(err).Response() }
+
+func (p proto) Success(filename string, body io.Reader) *types.Response {
+ return File(GuessItemType(filename), body)
+}
+
+func (p proto) ParseResponse(input io.Reader) (*types.Response, error) {
+ return &types.Response{Body: input, Status: MenuType}, nil
+}
+
+var ServerProtocol types.ServerProtocol = proto{}