proxy.go 936 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package routes
  2. import (
  3. "fmt"
  4. "net/http"
  5. "codeberg.org/vnpower/pixivfe/v2/core"
  6. )
  7. func SPximgProxy(w http.ResponseWriter, r *http.Request) error {
  8. URL := fmt.Sprintf("https://s.pximg.net/%s", r.URL.Path)
  9. req, err := http.NewRequestWithContext(r.Context(), "GET", URL, nil)
  10. if err != nil {
  11. return err
  12. }
  13. return core.ProxyRequest(w, req)
  14. }
  15. func IPximgProxy(w http.ResponseWriter, r *http.Request) error {
  16. URL := fmt.Sprintf("https://i.pximg.net/%s", r.URL.Path)
  17. req, err := http.NewRequestWithContext(r.Context(), "GET", URL, nil)
  18. if err != nil {
  19. return err
  20. }
  21. req.Header.Add("Referer", "https://www.pixiv.net/")
  22. return core.ProxyRequest(w, req)
  23. }
  24. func UgoiraProxy(w http.ResponseWriter, r *http.Request) error {
  25. URL := fmt.Sprintf("https://ugoira.com/api/mp4/%s", r.URL.Path)
  26. req, err := http.NewRequestWithContext(r.Context(), "GET", URL, nil)
  27. if err != nil {
  28. return err
  29. }
  30. return core.ProxyRequest(w, req)
  31. }