|
- package main
-
- import (
- "net/http"
- )
-
- type NotFoundRedirectRespWr struct {
- http.ResponseWriter // We embed http.ResponseWriter
- status int
- }
-
- func (w *NotFoundRedirectRespWr) WriteHeader(status int) {
- w.status = status // Store the status for our own use
- if status != http.StatusNotFound {
- w.ResponseWriter.WriteHeader(status)
- }
- }
-
- func (w *NotFoundRedirectRespWr) Write(p []byte) (int, error) {
- if w.status != http.StatusNotFound {
- return w.ResponseWriter.Write(p)
- }
- return len(p), nil // Lie that we successfully written it
- }
-
- func wrapHandler(h http.Handler) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path == "/" {
- leanworkInP2P(w, r) // StartPay(w, r)
- } else {
- h.ServeHTTP(w, r)
- }
- }
- }
|