Documentation
¶
Index ¶
Constants ¶
const ( StatusInput = 10 StatusSuccess = 20 StatusSuccessEndOfClientCertificateSession = 21 StatusRedirect = 30 StatusRedirectTemporary = 30 StatusRedirectPermanent = 31 StatusTemporaryFailure = 40 StatusCGIError = 42 StatusProxyError = 43 StatusSlowDown = 44 StatusPermanentFailure = 50 StatusNotFound = 51 StatusGone = 52 StatusProxyRequestRefused = 53 StatusBadRequest = 59 StatusClientCertificateRequired = 60 StatusTransientCertificateRequested = 61 StatusAuthorisedCertificateRequired = 62 StatusCertificateNotAccepted = 63 StatusFutureCertificateRejected = 64 StatusExpiredCertificateRejected = 65 )
Gemini status codes as defined in the Gemini spec Appendix 1.
Variables ¶
var DefaultClient = &Client{}
Functions ¶
func IsStatusValid ¶
IsStatusValid checks whether an int status is covered by the spec.
func ListenAndServe ¶
ListenAndServe create a TCP server on the specified address and pass new connections to the given handler. Each request is handled in a separate goroutine.
func SimplifyStatus ¶
SimplifyStatus simplify the response status by omiting the detailed second digit of the status code.
Types ¶
type Client ¶
type Client struct { // NoTimeCheck allows connections with expired or future certs if set to true. NoTimeCheck bool // NoHostnameCheck allows connections when the cert doesn't match the // requested hostname or IP. NoHostnameCheck bool // AllowInvalidStatuses means the client won't raise an error if a status // that is out of spec is returned. AllowInvalidStatuses bool // Insecure disables all TLS-based checks, use with caution. // It overrides all the variables above. Insecure bool }
type Handler ¶
Handler is the interface a struct need to implement to be able to handle Gemini requests
type Response ¶
type Response struct { Status int Meta string Body io.ReadCloser }
Response represent the response from a Gemini server.
func ErrorResponse ¶
ErrorResponse create a response from the given error with the error string as the Meta field. If the error is of type gemini.Error, the status will be taken from the status field, otherwise it will default to StatusTemporaryFailure. If the error is nil, the function will panic.