diff options
| author | Adnan Maolood <[email protected]> | 2020-10-24 15:15:32 -0400 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2020-10-24 15:15:32 -0400 |
| commit | f0345f349594b3bb93a45827c7f99688ce73ae34 (patch) | |
| tree | a1065b08973167e4a23ce6d91c9df3ab06209a41 /doc.go | |
| parent | Add Certificate helper function (diff) | |
| download | go-gemini-f0345f349594b3bb93a45827c7f99688ce73ae34.tar.xz go-gemini-f0345f349594b3bb93a45827c7f99688ce73ae34.zip | |
Rename repository to go-gemini
Diffstat (limited to 'doc.go')
| -rw-r--r-- | doc.go | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -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 |