Skip to content

Instantly share code, notes, and snippets.

@moreauadrien
Created March 20, 2023 15:33
Show Gist options
  • Save moreauadrien/c1c0f0528194c666e503aad5282749bb to your computer and use it in GitHub Desktop.
Save moreauadrien/c1c0f0528194c666e503aad5282749bb to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
"os"
"strings"
)
func main() {
challenge := os.Args[1]
fileName := strings.Split(challenge, ".")[0]
route := fmt.Sprintf("/.well-known/acme-challenge/%v", fileName)
fmt.Println(route)
http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(challenge))
})
if err := http.ListenAndServe(":80", nil); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment