Commit Graph

14 Commits

Author SHA1 Message Date
Adnan Maolood
d01d50ff1a Simplify ResponseWriter implementation 2021-01-10 00:50:35 -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
85f8e84bd5 Rename (*ResponseWriter).SetMimetype to SetMediaType 2020-11-09 13:44:42 -05:00
Adnan Maolood
cec1f118fb Remove some unnecessary errors 2020-11-04 23:46:05 -05:00
Adnan Maolood
34ae2a9066 Use strings.Builder in Fingerprint 2020-10-28 15:14:24 -04:00
Adnan Maolood
9079be9019 Add ServeFile function 2020-10-27 13:32:48 -04:00
Adnan Maolood
79165833de Add (*ResponseWriter).WriteStatus function 2020-10-27 13:30:35 -04:00
Adnan Maolood
ca118681c0 Update documentation 2020-10-24 15:29:12 -04:00
Adnan Maolood
f0345f3495 Rename repository to go-gemini 2020-10-24 15:15:32 -04:00
Adnan Maolood
aeff8a051c Rename Handler to Responder 2020-10-21 16:28:50 -04:00
adnano
faf94d8ba5 Rename rw, req to w, r 2020-10-13 20:22:12 -04:00
adnano
4189a4f717 Move errors to gemini.go 2020-10-13 20:10:04 -04:00
adnano
96390291bc Detect mimetypes 2020-10-11 20:13:53 -04:00
adnano
7fdc28d5be Move filesystem code to its own file 2020-10-11 18:57:04 -04:00