summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-01-17 15:59:29 -0700
committertjpcc <tjp@ctrl-c.club>2023-01-17 15:59:29 -0700
commit2ef530daa47b301a40c1ee93cd43b8f36fc68c0b (patch)
treeb9753719f5f0e5312bb5008d40f40247ce14e15a /server.go
parent30e21f8513d49661cb6e1583d301e34e898d48a9 (diff)
pull request, response, handlers out of the gemini package
Diffstat (limited to 'server.go')
-rw-r--r--server.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/server.go b/server.go
new file mode 100644
index 0000000..96b6433
--- /dev/null
+++ b/server.go
@@ -0,0 +1,36 @@
+package gus
+
+// Server is a type which can serve a protocol.
+type Server interface {
+ // Serve blocks listening for connections on an interface.
+ //
+ // It will only return after Close() has been called.
+ Serve() error
+
+ // Close initiates a graceful shutdown of the server.
+ //
+ // It blocks until all resources have been cleaned up and all
+ // outstanding requests have been handled and responses sent.
+ Close()
+
+ // Closed indicates whether Close has been called.
+ //
+ // It may be true even if the graceful shutdown procedure
+ // hasn't yet completed.
+ Closed() bool
+
+ // Network returns the network type on which the server is running.
+ Network() string
+
+ // Address returns the address on which the server is listening.
+ Address() string
+
+ // Hostname returns just the hostname portion of the listen address.
+ Hostname() string
+
+ // Port returns the port on which the server is listening.
+ //
+ // It will return the empty string if the network type does not
+ // have ports (unix sockets, for example).
+ Port() string
+}