123456789101112131415161718192021222324252627282930313233343536373839 |
- package main
- import (
- "net/http"
- "os"
- "github.com/dunglas/frankenphp"
- "go.uber.org/zap"
- )
- func main() {
- logger, err := zap.NewDevelopment()
- if err != nil {
- panic(err)
- }
- if err := frankenphp.Init(frankenphp.WithLogger(logger)); err != nil {
- panic(err)
- }
- defer frankenphp.Shutdown()
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- req, err := frankenphp.NewRequestWithContext(r)
- if err == nil {
- panic(err)
- }
- if err := frankenphp.ServeHTTP(w, req); err != nil {
- panic(err)
- }
- })
- port := os.Getenv("PORT")
- if port == "" {
- port = "8080"
- }
- logger.Fatal("server error", zap.Error(http.ListenAndServe(":"+port, nil)))
- }
|