aboutsummaryrefslogtreecommitdiff
path: root/doc.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-10-24 15:15:32 -0400
committerAdnan Maolood <[email protected]>2020-10-24 15:15:32 -0400
commitf0345f349594b3bb93a45827c7f99688ce73ae34 (patch)
treea1065b08973167e4a23ce6d91c9df3ab06209a41 /doc.go
parentAdd Certificate helper function (diff)
downloadgo-gemini-f0345f349594b3bb93a45827c7f99688ce73ae34.tar.xz
go-gemini-f0345f349594b3bb93a45827c7f99688ce73ae34.zip
Rename repository to go-gemini
Diffstat (limited to 'doc.go')
-rw-r--r--doc.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/doc.go b/doc.go
index 84dea50..9d519a0 100644
--- a/doc.go
+++ b/doc.go
@@ -1,10 +1,10 @@
/*
-Package gmi implements the Gemini protocol.
+Package gemini implements the Gemini protocol.
Send makes a Gemini request with the default client:
- req := gmi.NewRequest("gemini://example.com")
- resp, err := gmi.Send(req)
+ req := gemini.NewRequest("gemini://example.com")
+ resp, err := gemini.Send(req)
if err != nil {
// handle error
}
@@ -12,7 +12,7 @@ Send makes a Gemini request with the default client:
For control over client behavior, create a custom Client:
- var client gmi.Client
+ var client gemini.Client
resp, err := client.Send(req)
if err != nil {
// handle error
@@ -29,20 +29,20 @@ Custom clients can load their own list of known hosts:
Clients can control when to trust certificates with TrustCertificate:
- client.TrustCertificate = func(hostname string, cert *x509.Certificate, knownHosts *gmi.KnownHosts) error {
+ client.TrustCertificate = func(hostname string, cert *x509.Certificate, knownHosts *gemini.KnownHosts) error {
return knownHosts.Lookup(hostname, cert)
}
If a server responds with StatusCertificateRequired, the default client will generate a certificate and resend the request with it. Custom clients can do so in GetCertificate:
- client.GetCertificate = func(hostname string, store *gmi.CertificateStore) *tls.Certificate {
+ client.GetCertificate = func(hostname string, store *gemini.CertificateStore) *tls.Certificate {
// If the certificate is in the store, return it
if cert, err := store.Lookup(hostname); err == nil {
return &cert
}
// Otherwise, generate a certificate
duration := time.Hour
- cert, err := gmi.NewCertificate(hostname, duration)
+ cert, err := gemini.NewCertificate(hostname, duration)
if err != nil {
return nil
}
@@ -53,7 +53,7 @@ If a server responds with StatusCertificateRequired, the default client will gen
Server is a Gemini server.
- var server gmi.Server
+ var server gemini.Server
Servers must be configured with certificates:
@@ -64,13 +64,13 @@ Servers must be configured with certificates:
Servers can accept requests for multiple hosts and schemes:
- server.RegisterFunc("example.com", func(w *gmi.ResponseWriter, r *gmi.Request) {
+ server.RegisterFunc("example.com", func(w *gemini.ResponseWriter, r *gemini.Request) {
fmt.Fprint(w, "Welcome to example.com")
})
- server.RegisterFunc("example.org", func(w *gmi.ResponseWriter, r *gmi.Request) {
+ server.RegisterFunc("example.org", func(w *gemini.ResponseWriter, r *gemini.Request) {
fmt.Fprint(w, "Welcome to example.org")
})
- server.RegisterFunc("http://example.net", func(w *gmi.ResponseWriter, r *gmi.Request) {
+ server.RegisterFunc("http://example.net", func(w *gemini.ResponseWriter, r *gemini.Request) {
fmt.Fprint(w, "Proxied content from http://example.net")
})
@@ -81,4 +81,4 @@ To start the server, call ListenAndServe:
// handle error
}
*/
-package gmi
+package gemini