Fork of go-gemini
Go to file
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
examples examples/client: Fix fingerprint check 2020-12-19 13:44:33 -05:00
.gitignore Implement certificate creation 2020-09-27 13:50:48 -04:00
cert.go Fix locking up of KnownHostsFile and CertificateDir 2020-12-17 17:15:24 -05:00
client.go Add missing error handling 2021-01-09 23:53:07 -05:00
fs.go Add missing error handling 2021-01-09 23:53:07 -05:00
gemini.go Add ReadRequest and ReadResponse functions 2020-12-18 01:42:05 -05:00
go.mod Rename repository to go-gemini 2020-10-24 15:15:32 -04:00
LICENSE Rename repository to go-gemini 2020-10-24 15:15:32 -04:00
mux.go Add missing error handling 2021-01-09 23:53:07 -05:00
query.go Update QueryEscape documentation 2020-12-18 00:26:47 -05:00
README.md Add contributing instructions to README.md 2020-10-24 21:55:58 -04:00
request.go Update Request documentation 2020-12-18 01:43:18 -05:00
response.go client: Close connection for unsuccessful responses 2020-12-22 19:22:01 -05:00
server.go Add missing error handling 2021-01-09 23:53:07 -05:00
status.go Remove Redirect and PermanentRedirect functions 2020-10-31 16:51:10 -04:00
text.go Add missing error handling 2021-01-09 23:53:07 -05:00
tofu.go Add missing error handling 2021-01-09 23:53:07 -05:00
vendor.go Rename repository to go-gemini 2020-10-24 15:15:32 -04:00

go-gemini

GoDoc

Package gemini implements the Gemini protocol in Go.

It aims to provide an API similar to that of net/http to make it easy to develop Gemini clients and servers.

Usage

import "git.sr.ht/~adnano/go-gemini"

Examples

There are a few examples provided in the examples directory. To run an example:

go run examples/server.go

Contributing

Send patches and questions to ~adnano/go-gemini-devel.

Subscribe to release announcements on ~adnano/go-gemini-announce.