Categorygit.sr.ht/~adnano/go-gemini
modulepackage
0.2.5
Repository: https://git.sr.ht/~adnano/go-gemini
Documentation: pkg.go.dev

# README

go-gemini

godocs.io builds.sr.ht status

Package gemini implements the Gemini protocol in Go. It provides an API similar to that of net/http to facilitate the development of Gemini clients and servers.

Compatible with version v0.16.0 of the Gemini specification.

Usage

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

Note that some filesystem-related functionality is only available on Go 1.16 or later as it relies on the io/fs package.

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.

License

go-gemini is licensed under the terms of the MIT license (see LICENSE). Portions of this library were adapted from Go and are governed by a BSD-style license (see LICENSE-GO). Those files are marked accordingly.

# Packages

Package certificate provides functions for creating and storing TLS certificates.
Package tofu implements trust on first use using hosts and fingerprints.

# Functions

FileServer returns a handler that serves Gemini requests with the contents of the provided file system.
LoggingMiddleware returns a handler that wraps h and logs Gemini requests and their responses to the log package's standard logger.
NewRequest returns a new request.
NotFoundHandler returns a simple request handler that replies to each request with a “51 Not found” reply.
ParseLines parses Gemini text from the provided io.Reader.
ParseText parses Gemini text from the provided io.Reader.
QueryEscape escapes a string for use in a Gemini URL query.
QueryUnescape unescapes a Gemini URL query.
ReadRequest reads and parses an incoming request from r.
ReadResponse reads a Gemini response from the provided io.ReadCloser.
ServeFile responds to the request with the contents of the named file or directory.
StatusHandler returns a request handler that responds to each request with the provided status code and meta.
StripPrefix returns a handler that serves Gemini requests by removing the given prefix from the request URL's Path (and RawPath if set) and invoking the handler h.
TimeoutHandler returns a Handler that runs h with the given time limit.

# Constants

Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.
Gemini status codes.

# Variables

ErrBodyNotAllowed is returned by ResponseWriter.Write calls when the response status code does not permit a body.
Errors.
Errors.

# Structs

A Client is a Gemini client.
LineLink is a link line.
Mux is a Gemini request multiplexer.
A Request represents a Gemini request received by a server or to be sent by a client.
Response represents the response from a Gemini request.
A Server defines parameters for running a Gemini server.

# Interfaces

A Handler responds to a Gemini request.
Line represents a line of a Gemini text response.
A ResponseWriter interface is used by a Gemini handler to construct a Gemini response.

# Type aliases

The HandlerFunc type is an adapter to allow the use of ordinary functions as Gemini handlers.
LineHeading1 is a first-level heading line.
LineHeading2 is a second-level heading line.
LineHeading3 is a third-level heading line.
LineListItem is an unordered list item line.
LinePreformattedText is a preformatted text line.
LinePreformattingToggle is a preformatting toggle line.
LineQuote is a quote line.
LineText is a text line.
Status represents a Gemini status code.
Text represents a Gemini text response.