Documentation
¶
Overview ¶
Package server provides utilities for creating a functioning and useful Gemini server
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler func(request Request)
A Handler is a function to handle a Request by calling its various methods. The function is called when a request that it can handle is made, as outlined in Server.RegisterHandler
type Request ¶
type Request struct {
// URI contains a [url.URL] object corresponding to the URL of the request.
URI url.URL
// Params contains a map of URL params passed into the request. Nil if there are no params.
Params map[string]string
// contains filtered or unexported fields
}
Request wraps a Gemini request.
func (*Request) Error ¶
Error responds with an error code and message After calling this method, the Request has been terminated.
func (*Request) Gemtext ¶
Gemtext responds using a gemtext string and status code 20. After calling this method, the Request has been terminated.
func (*Request) GemtextFile ¶
GemtextFile responds using gemtext from a file and status code 20. After calling this method, the Request has been terminated.
func (*Request) GetClientCertificates ¶
func (r *Request) GetClientCertificates() []*x509.Certificate
GetClientCertificates retrieves the client certificate(s) for the Request
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server contains information required to run a TCP/TLS service capable of serving Gemini content over the internet
func (*Server) ListenAndServe ¶
ListenAndServe starts the Server running on a specific port using the provided TLS configuration
func (*Server) RegisterHandler ¶
RegisterHandler sets up a Handler to handle any Request that comes to a path
func (*Server) RegisterTitanHandler ¶ added in v0.4.0
func (s *Server) RegisterTitanHandler(path string, handler TitanHandler)
RegisterTitanHandler sets up a TitanHandler to handle any TitanRequest that comes to a path
type TitanHandler ¶ added in v0.4.0
type TitanHandler func(request TitanRequest)
A TitanHandler is a function to handle a TitanRequest by calling its various methods. The function is called when a titan request that it can handle is made as outlined in Server.RegisterTitanHandler
type TitanRequest ¶ added in v0.4.0
type TitanRequest struct {
Request
// Token contains the answer to the security question, or an empty string
Token string
// MIMEType contains the MIME type of the data. Defaults to "text/gemini"
MIMEType string
// Body contains the data sent by the client
Body []byte
}
TitanRequest wraps a Titan request.
Contains Request, so can be used like a Gemini request as well.