<commit_before>package server

import (
	"fmt"
	"net/http"
	"net/http/pprof"
	"net/url"
	"time"
	"expvar"

	"github.com/pressly/cji"
	"github.com/pressly/consistentrd"
	"github.com/pressly/imgry"
	"github.com/unrolled/render"
	"github.com/pressly/gohttpware/heartbeat"
	"github.com/rcrowley/go-metrics"
	"github.com/zenazn/goji/web/middleware"
)

func NewRouter() http.Handler {
	conrd, err := consistentrd.New(app.Config.Cluster.LocalNode, app.Config.Cluster.Nodes)
	if err != nil {
		panic(err)
	}

	r := cji.NewRouter()

	r.Use(middleware.EnvInit)
	r.Use(middleware.RequestID)
	r.Use(middleware.RealIP)
	r.Use(RequestLogger)
	r.Use(heartbeat.Route("/ping"))

	r.Mount("/debug", Profiler())

	r.Get("/", trackRoute("root"), func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(200)
		w.Write([]byte("."))
	})

	r.Get("/fetch", trackRoute("bucketV0GetItem"), BucketV0FetchItem) // Deprecated: for Pressilla v2 apps

	r.Get("/info", trackRoute("imageInfo"), GetImageInfo)

	r.Get("/:bucket", conrd.RouteWithParams("url"), trackRoute("bucketV1GetItem"), BucketGetIndex)
	r.Post("/:bucket", BucketImageUpload)

	r.Get("/:bucket/fetch", conrd.RouteWithParams("url"), trackRoute("bucketV1GetItem"), BucketFetchItem)
<commit_msg>Force, no-cache on profiler endpoints<commit_after>package server

import (
	"fmt"
	"net/http"
	"net/http/pprof"
	"net/url"
	"time"
	"expvar"

	"github.com/pressly/cji"
	"github.com/pressly/consistentrd"
	"github.com/pressly/imgry"
	"github.com/unrolled/render"
	"github.com/pressly/gohttpware/heartbeat"
	"github.com/rcrowley/go-metrics"
	"github.com/zenazn/goji/web/middleware"
)

func NewRouter() http.Handler {
	conrd, err := consistentrd.New(app.Config.Cluster.LocalNode, app.Config.Cluster.Nodes)
	if err != nil {
		panic(err)
	}

	r := cji.NewRouter()

	r.Use(middleware.EnvInit)
	r.Use(middleware.RequestID)
	r.Use(middleware.RealIP)
	r.Use(RequestLogger)
	r.Use(heartbeat.Route("/ping"))

	r.Mount("/debug", middleware.NoCache, Profiler())

	r.Get("/", trackRoute("root"), func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(200)
		w.Write([]byte("."))
	})

	r.Get("/fetch", trackRoute("bucketV0GetItem"), BucketV0FetchItem) // Deprecated: for Pressilla v2 apps

	r.Get("/info", trackRoute("imageInfo"), GetImageInfo)

	r.Get("/:bucket", conrd.RouteWithParams("url"), trackRoute("bucketV1GetItem"), BucketGetIndex)
	r.Post("/:bucket", BucketImageUpload)

	r.Get("/:bucket/fetch", conrd.RouteWithParams("url"), trackRoute("bucketV1GetItem"), BucketFetchItem)

{'fraction_non_alphanumeric': 0.18312101910828024, 'fraction_numerical': 0.006369426751592357, 'mean_word_length': 5.314070351758794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '61683', 'n_tokens_mistral': 996, 'n_tokens_neox': 966, 'n_words': 135}