Move errors to gemini.go
This commit is contained in:
parent
2c1081966d
commit
4189a4f717
@ -4,21 +4,12 @@ import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Client errors.
|
||||
var (
|
||||
ErrInvalidURL = errors.New("gemini: invalid URL")
|
||||
ErrInvalidResponse = errors.New("gemini: invalid response")
|
||||
ErrCertificateUnknown = errors.New("gemini: unknown certificate")
|
||||
ErrCertificateNotTrusted = errors.New("gemini: certificate is not trusted")
|
||||
)
|
||||
|
||||
// Request represents a Gemini request.
|
||||
type Request struct {
|
||||
// URL specifies the URL being requested.
|
||||
|
6
fs.go
6
fs.go
@ -1,7 +1,6 @@
|
||||
package gmi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"mime"
|
||||
"os"
|
||||
@ -15,11 +14,6 @@ func init() {
|
||||
mime.AddExtensionType(".gemini", "text/gemini")
|
||||
}
|
||||
|
||||
// FileServer errors.
|
||||
var (
|
||||
ErrNotAFile = errors.New("gemini: not a file")
|
||||
)
|
||||
|
||||
// FileServer takes a filesystem and returns a Handler which uses that filesystem.
|
||||
// The returned Handler sanitizes paths before handling them.
|
||||
func FileServer(fsys FS) Handler {
|
||||
|
14
gemini.go
14
gemini.go
@ -3,6 +3,7 @@ package gmi
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@ -39,10 +40,21 @@ const (
|
||||
StatusClassCertificateRequired = 6
|
||||
)
|
||||
|
||||
// Errors.
|
||||
var (
|
||||
ErrInvalidURL = errors.New("gmi: invalid URL")
|
||||
ErrInvalidResponse = errors.New("gmi: invalid response")
|
||||
ErrCertificateUnknown = errors.New("gmi: unknown certificate")
|
||||
ErrCertificateExpired = errors.New("gmi: certificate expired")
|
||||
ErrCertificateNotTrusted = errors.New("gmi: certificate is not trusted")
|
||||
ErrNotAFile = errors.New("gmi: not a file")
|
||||
ErrBodyNotAllowed = errors.New("gmi: response status code does not allow for body")
|
||||
)
|
||||
|
||||
// DefaultClient is the default client. It is used by Send.
|
||||
//
|
||||
// On the first request, DefaultClient will load the default list of known hosts.
|
||||
var DefaultClient = &Client{}
|
||||
var DefaultClient Client
|
||||
|
||||
var (
|
||||
crlf = []byte("\r\n")
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
@ -16,12 +15,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Server errors.
|
||||
var (
|
||||
ErrBodyNotAllowed = errors.New("gemini: response status code does not allow for body")
|
||||
ErrCertificateExpired = errors.New("gemini: certificate expired")
|
||||
)
|
||||
|
||||
// Server is a Gemini server.
|
||||
type Server struct {
|
||||
// Addr specifies the address that the server should listen on.
|
||||
|
Loading…
Reference in New Issue
Block a user