~benvh/gomini

golang gemini protocol client/server library
Added proxy, run and vhost handlers
Added NewKnownHosts method
[PATCH] Made server example in README actually compile and run

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~benvh/gomini
read/write
git@git.sr.ht:~benvh/gomini

You can also use your local clone with git send-email.

#gomini

go client and server implementation of the gemini protocol https://gemini.circumlunar.space/

#docs

TODO - doc link

#quick start examples

#client
import (
    "git.sr.ht/~benvh/gomini"
)

func main() {
    knownHosts := &gomini.KnownHosts{TrustNewHosts: true}
    response, err := gomini.Fetch("gemini://benvh.tech/", knownHosts)

	if err != nil {
        panic(err)
    }

    fmt.Println("%d - %s", response.Status, response.Meta)

    // ...
}


#server
import (
    "crypto/tls"
    "net/url"

    "git.sr.ht/~benvh/gomini"
)

func main() {
    cert, err := tls.LoadX509KeyPair("cert.pem", "key.pem")
    if err != nil {
        panic(err)
    }

    tlsConfig := &tls.Config{Certificates: []tls.Certificate{cert}}
    s := gomini.NewServer(tlsConfig)

    handler := new(gomini.ServeMux)
    handler.Handle(`^/`, gomini.FileHandler("./public"))

    handler.Handle(`^/foo/bar`, gomini.HandlerFunc(func(resp gomini.ResponseWriter, req *url.URL) {
        resp.WriteHeader(gomini.StatusSuccess, "text/plain")
        resp.Write([]byte("foobar"))
    }))

    s.ListenAndServe("0.0.0.0:1965", handler)
}