Documentation ¶
Index ¶
- Constants
- func ConnHandler(cc *fastnet.ConnCtx) error
- func MimeType(filename string) (string, bool)
- func NewServer() fastnet.Server
- func ServeFile(ctx *fastnet.RequestCtx, rw ResponseWriter, r *Request, file *os.File)
- func StatusText(code int) string
- func ToHandler(h Handler) fastnet.Handler
- type Handler
- type HandlerFunc
- type Request
- type ResponseWriter
Constants ¶
const ( StatusInput = 10 StatusSensitive = 11 StatusSuccess = 20 StatusTemporaryRedirect = 30 StatusPermanentRedirect = 31 StatusTemporaryFailure = 40 StatusCGIError = 42 StatusProxyError = 43 StatusSlowDown = 44 StatusPermanentFailure = 50 StatusNotFound = 51 StatusGone = 52 StatusProxyRequestRefused = 53 StatusBadRequest = 59 StatusClientCertificateRequired = 60 StatusClientCertificateNotAuthorized = 61 StatusCertificateNotValid = 62 )
Gemini status header codes
Variables ¶
This section is empty.
Functions ¶
func ConnHandler ¶
func ConnHandler(cc *fastnet.ConnCtx) error
ConnHandler is the gemini new connection handler function. This should be set to the fastnet.Server's ConnHandler member, or simply create a new server via NewServer()
func NewServer ¶
func NewServer() fastnet.Server
NewServer returns a new fastnet.Server instance for the supplied Config with gemini ConnHandler set
func ServeFile ¶
func ServeFile(ctx *fastnet.RequestCtx, rw ResponseWriter, r *Request, file *os.File)
ServeFile attempts to parse a mime-type from either the file's extension, or first 512-bytes of the file, to set an appropriate response header. Before finally serving content to the client
func StatusText ¶ added in v1.1.0
StatusText returns string representation of supplied status code, or empty
Types ¶
type Handler ¶
type Handler interface {
Serve(ctx *fastnet.RequestCtx, rw ResponseWriter, r *Request)
}
Handler is a gemini specific request handler interface, use ToHandler() to convert to fastnet.Handler
type HandlerFunc ¶
type HandlerFunc func(ctx *fastnet.RequestCtx, rw ResponseWriter, r *Request)
Handler is a gemini specific requeust handler function which implements fastnet.Handler
func (HandlerFunc) Serve ¶
func (h HandlerFunc) Serve(ctx *fastnet.RequestCtx)
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request contains information regarding a Gemini request. It is NOT valid use this object or any mutable data types contained within (e.g. Bytes(), StringPtr() ) after the handler this was originally passed to has returned. Do NOT assume it is thread-safe
func GetRequest ¶
func GetRequest(ctx *fastnet.RequestCtx) *Request
GetRequest fetches the stored Request object from a RequestCtx
func (*Request) FullURI ¶
func (r *Request) FullURI() bytes.Bytes
FullURI returns a Bytes representation of the full URI (scheme + authority + path + query)
func (*Request) Host ¶
func (r *Request) Host() bytes.Bytes
Host returns the host Bytes from the URI
func (*Request) Path ¶
func (r *Request) Path() bytes.Bytes
Path returns the path Bytes from the URI
func (*Request) Query ¶
func (r *Request) Query() *uri.QueryParams
Query returns the query parameters from the URI
func (*Request) RequestURI ¶
func (r *Request) RequestURI() bytes.Bytes
RequestURI returns a Bytes representation of the request URI (path + query)
func (*Request) Scheme ¶
func (r *Request) Scheme() bytes.Bytes
Scheme returns the scheme Bytes from the URI
func (*Request) TLS ¶
func (r *Request) TLS() *tls.ConnectionState
TLS returns the tls ConnectionState associated with this request
type ResponseWriter ¶
type ResponseWriter interface { // Status returns the current set status code (if any) Status() int // Meta returns the currently set status meta (if any) Meta() string // WriteHeader writes the supplied status code and meta to the response Writer WriteHeader(code int, meta string) error io.Writer io.ReaderFrom }
ResponseWriter defines a means of responding to a Gemini request. It is NOT valid to attempt writes after the handler this was originally handed to has returned. Do NOT assume it is thread-safe
func GetResponseWriter ¶ added in v1.1.0
func GetResponseWriter(ctx *fastnet.RequestCtx) ResponseWriter
GetResponse fetches the Gemini Response object from a RequestCtx