Commit Graph

18 Commits

Author SHA1 Message Date
Adnan Maolood 3d2110d90f mux: Tweak documentation 2021-06-26 20:26:30 -04:00
Adnan Maolood fb0d4d24bd mux: Remove support for handling schemes
Also fix redirection to subtree roots for wildcard patterns and patterns
without a host name.
2021-06-26 18:50:09 -04:00
Adnan Maolood c68ce57488 mux: Add copyright notice 2021-03-24 13:09:53 -04:00
Adnan Maolood 1fdef9b608 Rename ServeMux to Mux 2021-03-15 15:44:35 -04:00
Adnan Maolood 3660698a4b Make ResponseWriter an interface
Make ResponseWriter an interface with an unexported method. Implementors
must embed a ResponseWriter from elsewhere. This gives us the
flexibility of an interface while allowing us to add new methods in the
future.
2021-02-24 00:13:46 -05:00
Adnan Maolood a65c3c3d4f Make ResponseWriter a struct
Make ResponseWriter a struct again so that it can be extended in a
backwards-compatible way.
2021-02-23 20:41:16 -05:00
Adnan Maolood 4e25d2c3f9 ServeMux.HandleFunc: Take a HandlerFunc argument 2021-02-23 09:49:20 -05:00
Adnan Maolood fadb2aed97 mux: Use StatusHandler instead of RedirectHandler 2021-02-20 16:45:37 -05:00
Adnan Maolood e9a68917c9 handler: Make ServeGemini accept a Context 2021-02-20 15:49:14 -05:00
Adnan Maolood 76967dad2e mux: Reject empty patterns 2021-02-19 18:06:54 -05:00
Adnan Maolood f3cd70612b mux: Implement matching of schemes and hostnames 2021-02-17 20:09:42 -05:00
Adnan Maolood 110c2de6de Redesign ResponseWriter interface 2021-02-17 13:36:16 -05:00
Adnan Maolood 5a784693ef server: Rename responder to handler 2021-02-15 01:15:23 -05:00
Adnan Maolood f6824bd813 Make ResponseWriter an interface 2021-02-09 09:46:18 -05:00
Adnan Maolood 7910ed433b Rename Responder to Handler 2021-02-08 12:50:52 -05:00
Hugo Wetterberg f2921a396f Add missing error handling
Error handling is currently missing is a couple of places. Most of
them are i/o related.

This change adds checks, an therefore sometimes also has to change
function signatures by adding an error return value. In the case of
the response writer the status and meta handling is changed and this
also breaks the API.

In some places where we don't have any reasonable I've added
assignment to a blank identifier to make it clear that we're ignoring
an error.

text: read the Err() that can be set by the scanner.

client: check if conn.SetDeadline() returns an error.

client: check if req.Write() returns an error.

fs: panic if mime type registration fails.

server: stop performing i/o in Header/Status functions

By deferring the actual header write to the first Write() or Flush()
call we don't have to do any error handling in Header() or Status().

As Server.respond() now defers a ResponseWriter.Flush() instead of
directly flushing the underlying bufio.Writer this has the added
benefit of ensuring that we always write a header
to the client, even if the responder is a complete NOOP.

tofu: return an error if we fail to write to the known hosts writer.
2021-01-09 23:53:07 -05:00
Adnan Maolood 63b9b484d1 Remove Redirect and PermanentRedirect functions
Use (*ResponseWriter).WriteHeader instead.
2020-10-31 16:51:10 -04:00
Adnan Maolood 7f0b1fa8a1 Refactor server certificates 2020-10-28 15:03:54 -04:00