github.com/kelleygo/clashcore@v1.0.2/hub/route/cache.go (about)

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