This package allows you to start an HTTP server that can be extended by other packages.
Initially, I looked for some packages that would simplify the implementation of an HTTP server compatible with HTTP3.
go get github.com/Lucas-Palomo/go-http-server-box
package main
import (
"github.com/Lucas-Palomo/go-http-server-box/server"
"net/http"
)
func main() {
app := server.New(":8080", server.HTTP3)
err := app.LoadTLSCert("./certs/test_cert.pem", "./certs/test_cert.key")
if err != nil {
panic(err)
}
handler := http.NewServeMux()
handler.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
w.WriteHeader(http.StatusOK)
})
server.Launch(app, handler)
}
package main
import (
"github.com/Lucas-Palomo/go-http-server-box/server"
"github.com/labstack/echo/v4"
"net/http"
)
func main() {
app := server.New(":8080", server.HTTP3)
err := app.LoadTLSCert("./certs/test_cert.pem", "./certs/test_cert.key")
if err != nil {
panic(err)
}
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
server.Launch(app, e)
}