payment gateway for rpn cn
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 satır
744B

  1. package main
  2. import (
  3. "net/http"
  4. )
  5. type NotFoundRedirectRespWr struct {
  6. http.ResponseWriter // We embed http.ResponseWriter
  7. status int
  8. }
  9. func (w *NotFoundRedirectRespWr) WriteHeader(status int) {
  10. w.status = status // Store the status for our own use
  11. if status != http.StatusNotFound {
  12. w.ResponseWriter.WriteHeader(status)
  13. }
  14. }
  15. func (w *NotFoundRedirectRespWr) Write(p []byte) (int, error) {
  16. if w.status != http.StatusNotFound {
  17. return w.ResponseWriter.Write(p)
  18. }
  19. return len(p), nil // Lie that we successfully written it
  20. }
  21. func wrapHandler(h http.Handler) http.HandlerFunc {
  22. return func(w http.ResponseWriter, r *http.Request) {
  23. if r.URL.Path == "/" {
  24. StartPay(w, r)
  25. } else {
  26. h.ServeHTTP(w, r)
  27. }
  28. }
  29. }