()
| 804 | } |
| 805 | |
| 806 | func ExampleServeHTTP() { |
| 807 | if err := frankenphp.Init(); err != nil { |
| 808 | panic(err) |
| 809 | } |
| 810 | defer frankenphp.Shutdown() |
| 811 | |
| 812 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
| 813 | // Drop headers whose name contains an underscore: CGI maps dashes to |
| 814 | // underscores, so "Foo_Bar" would be indistinguishable from "Foo-Bar" |
| 815 | // in $_SERVER and could spoof any header an app or proxy trusts. |
| 816 | // Whitelist any you genuinely need. |
| 817 | for name := range r.Header { |
| 818 | if strings.ContainsRune(name, '_') { |
| 819 | delete(r.Header, name) |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | req, err := frankenphp.NewRequestWithContext(r, frankenphp.WithRequestDocumentRoot("/path/to/document/root", false)) |
| 824 | if err != nil { |
| 825 | panic(err) |
| 826 | } |
| 827 | |
| 828 | if err := frankenphp.ServeHTTP(w, req); err != nil { |
| 829 | panic(err) |
| 830 | } |
| 831 | }) |
| 832 | log.Fatal(http.ListenAndServe(":8080", nil)) |
| 833 | } |
| 834 | |
| 835 | func BenchmarkHelloWorld(b *testing.B) { |
| 836 | require.NoError(b, frankenphp.Init()) |
nothing calls this directly
no test coverage detected