mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-28 22:39:05 +08:00
golint
This commit is contained in:
2
db/db.go
2
db/db.go
@@ -2,12 +2,14 @@ package db
|
||||
|
||||
import "gopkg.in/mgo.v2"
|
||||
|
||||
// Mongo contains the mongo connection info
|
||||
type Mongo struct {
|
||||
URL string
|
||||
Database string
|
||||
CollectionName string
|
||||
}
|
||||
|
||||
// Collection returns the goreportcard mongo collection
|
||||
func (db *Mongo) Collection() (*mgo.Collection, error) {
|
||||
session, err := mgo.Dial(db.URL)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AssetsHandler handles serving static files
|
||||
func AssetsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("Serving " + r.URL.Path[1:])
|
||||
http.ServeFile(w, r, r.URL.Path[1:])
|
||||
|
||||
@@ -56,6 +56,7 @@ func badgeURL(grade Grade) string {
|
||||
return url
|
||||
}
|
||||
|
||||
// BadgeHandler handles fetching the badge images
|
||||
func BadgeHandler(w http.ResponseWriter, r *http.Request, org, repo string) {
|
||||
name := fmt.Sprintf("%s/%s", org, repo)
|
||||
resp, err := newChecksResp(name, false)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
||||
// CheckHandler handles the request for checking a repo
|
||||
func CheckHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ func add(x, y int) int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
// HighScoresHandler handles the stats page
|
||||
func HighScoresHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var highScores []struct {
|
||||
Repo string
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// HomeHandler handles the homepage
|
||||
func HomeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("Serving home page")
|
||||
if r.URL.Path[1:] == "" {
|
||||
|
||||
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import "net/http"
|
||||
|
||||
// ReportHandler handles the report page
|
||||
func ReportHandler(w http.ResponseWriter, r *http.Request, org, repo string) {
|
||||
http.ServeFile(w, r, "templates/home.html")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user