Rename repository to go-gemini

This commit is contained in:
Adnan Maolood
2020-10-24 15:15:32 -04:00
parent 1634c2c11c
commit f0345f3495
18 changed files with 45 additions and 45 deletions

24
doc.go
View File

@@ -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