Simple hello world using certmagic in a golang project

I want to write a simple ‘hello’ world project using the cert magic library.

package main

import (





func timeHandler(w http.ResponseWriter, r *http.Request) {

tm := time.Now().Format(time.RFC1123)

w.Write([]byte("The time is: " + tm))


func main() {

mux := http.NewServeMux()

// Convert the timeHandler function to a http.HandlerFunc type.

th := http.HandlerFunc(timeHandler)

// And add it to the ServeMux.

mux.Handle("/time", th)


http.ListenAndServe(":8090", mux)


// err := certmagic.HTTPS([]string{"", ""}, mux)

// if err != nil {

// return err

// }

Where exactly should I wrap the above code to use the certmagic library?

There’s a snippet at the top of the CertMagic readme:

There you go :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.