This commit is contained in:
shawnps
2015-02-14 10:08:29 -08:00
parent 5927d9d69a
commit 8794a73695
7 changed files with 8 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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:])

View File

@@ -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)

View File

@@ -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")

View File

@@ -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

View File

@@ -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:] == "" {

View File

@@ -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")
}