Refactor: Add GetListener and TLS versions

This commit is contained in:
2025-01-24 19:01:12 -05:00
parent 27d7f247c3
commit 74ade60009
4 changed files with 137 additions and 48 deletions

32
examples/simple/main.go Normal file
View File

@ -0,0 +1,32 @@
package main
import (
"context"
"log"
"net/http"
"os"
"time"
"go.balki.me/anyhttp"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello\n"))
})
//log.Println("Got error: ", anyhttp.ListenAndServe(os.Args[1], nil))
ctx, err := anyhttp.Serve(os.Args[1], nil)
log.Printf("Got ctx: %v\n, err: %v", ctx, err)
log.Println(ctx.Addr())
if err != nil {
return
}
select {
case doneErr := <-ctx.Done:
log.Println(doneErr)
case <-time.After(1 * time.Minute):
log.Println("Awake")
ctx.Shutdown(context.TODO())
}
}

BIN
examples/simple/simple Executable file

Binary file not shown.