remove unused dev flag

This commit is contained in:
Shawn Smith
2018-12-20 11:04:58 +09:00
parent 40e1829866
commit 3ec84fb54f
4 changed files with 8 additions and 12 deletions

View File

@@ -16,8 +16,5 @@ test:
start:
go run main.go
start-dev:
go run main.go -http 127.0.0.1:8000 -dev
misspell:
find . -name '*.go' -not -path './vendor/*' -not -path './_repos/*' | xargs misspell -error

View File

@@ -9,12 +9,12 @@ import (
"github.com/gojp/goreportcard/check"
)
func badgePath(grade check.Grade, style string, dev bool) string {
func badgePath(grade check.Grade, style string) string {
return fmt.Sprintf("assets/badges/%s_%s.svg", strings.ToLower(string(grade)), strings.ToLower(style))
}
// BadgeHandler handles fetching the badge images
func BadgeHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool) {
func BadgeHandler(w http.ResponseWriter, r *http.Request, repo string) {
resp, err := newChecksResp(repo, false)
// See: http://shields.io/#styles
@@ -31,5 +31,5 @@ func BadgeHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool)
}
w.Header().Set("Cache-control", "no-store, no-cache, must-revalidate")
http.ServeFile(w, r, badgePath(resp.Grade, style, dev))
http.ServeFile(w, r, badgePath(resp.Grade, style))
}

View File

@@ -13,7 +13,7 @@ var domain = flag.String("domain", "goreportcard.com", "Domain used for your gor
var googleAnalyticsKey = flag.String("google_analytics_key", "UA-58936835-1", "Google Analytics Account Id")
// ReportHandler handles the report page
func ReportHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool) {
func ReportHandler(w http.ResponseWriter, r *http.Request, repo string) {
log.Printf("Displaying report: %q", repo)
t := template.Must(template.New("report.html").Delims("[[", "]]").ParseFiles("templates/report.html", "templates/footer.html"))
resp, err := getFromCache(repo)

View File

@@ -18,10 +18,9 @@ import (
var (
addr = flag.String("http", ":8000", "HTTP listen address")
dev = flag.Bool("dev", false, "dev mode")
)
func makeHandler(name string, dev bool, fn func(http.ResponseWriter, *http.Request, string, bool)) http.HandlerFunc {
func makeHandler(name string, fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
validPath := regexp.MustCompile(fmt.Sprintf(`^/%s/([a-zA-Z0-9\-_\/\.]+)$`, name))
@@ -54,7 +53,7 @@ func makeHandler(name string, dev bool, fn func(http.ResponseWriter, *http.Reque
return
}
fn(w, r, repo, dev)
fn(w, r, repo)
}
}
@@ -130,8 +129,8 @@ func main() {
http.HandleFunc(m.instrument("/assets/", handlers.AssetsHandler))
http.HandleFunc(m.instrument("/favicon.ico", handlers.FaviconHandler))
http.HandleFunc(m.instrument("/checks", handlers.CheckHandler))
http.HandleFunc(m.instrument("/report/", makeHandler("report", *dev, handlers.ReportHandler)))
http.HandleFunc(m.instrument("/badge/", makeHandler("badge", *dev, handlers.BadgeHandler)))
http.HandleFunc(m.instrument("/report/", makeHandler("report", handlers.ReportHandler)))
http.HandleFunc(m.instrument("/badge/", makeHandler("badge", handlers.BadgeHandler)))
http.HandleFunc(m.instrument("/high_scores/", handlers.HighScoresHandler))
http.HandleFunc(m.instrument("/about/", handlers.AboutHandler))
http.HandleFunc(m.instrument("/", handlers.HomeHandler))