cache.go 492 B

1234567891011121314151617181920212223242526
  1. package route
  2. import (
  3. "net/http"
  4. "github.com/metacubex/mihomo/component/resolver"
  5. "github.com/go-chi/chi/v5"
  6. "github.com/go-chi/render"
  7. )
  8. func cacheRouter() http.Handler {
  9. r := chi.NewRouter()
  10. r.Post("/fakeip/flush", flushFakeIPPool)
  11. return r
  12. }
  13. func flushFakeIPPool(w http.ResponseWriter, r *http.Request) {
  14. err := resolver.FlushFakeIP()
  15. if err != nil {
  16. render.Status(r, http.StatusBadRequest)
  17. render.JSON(w, r, newError(err.Error()))
  18. return
  19. }
  20. render.NoContent(w, r)
  21. }