Skip to content

Commit

Permalink
updates some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hkjn committed Dec 6, 2014
1 parent 990499d commit 7b61506
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
15 changes: 5 additions & 10 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@ import (
"hkjn.me/prober"
)

// linkInfo describes
type linkInfo struct {
Name, URL string
}

// getIndexData returns the data for the index page.
func getIndexData(w http.ResponseWriter, r *http.Request) (interface{}, error) {
data := struct {
ErrorMsg string
Links []linkInfo
ErrorMsg string
Links []struct {
Name, URL string
}
Probes []*prober.Probe
ProberDisabled bool
}{}
data.Links = []linkInfo{
// linkInfo{"TODO", "/fixme_link_to_dashboard_goes_here"},
}
data.Probes = GetProbes()
data.ProberDisabled = *proberDisabled
return data, nil
Expand Down
15 changes: 9 additions & 6 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ func serveISE(w http.ResponseWriter) {
http.Error(w, "Internal server error.", http.StatusInternalServerError)
}

// route describes how to serve HTTP on an endpoint.
type route interface {
Method() string
Pattern() string
HandlerFunc() http.HandlerFunc
Method() string // GET, POST, PUT, etc.
Pattern() string // URI for the route
HandlerFunc() http.HandlerFunc // HTTP handler func
}

// simpleRoute implements the route interface for simple endpoints.
// TODO: better naming.
// simpleRoute implements the route interface for endpoints.
type simpleRoute struct {
pattern, method string
method, pattern string
handlerFunc http.HandlerFunc
}

Expand All @@ -76,6 +76,7 @@ type page struct {
getTemplateData getDataFn
}

// newPage returns a new page.
func newPage(pattern string, tmpls []string, getData getDataFn) *page {
return &page{
pattern,
Expand All @@ -88,6 +89,8 @@ func (p page) Method() string { return "GET" }

func (p page) Pattern() string { return p.pattern }

// HandlerFunc returns the http handler func, which renders the
// template with the data.
func (p page) HandlerFunc() http.HandlerFunc {
fn := func(w http.ResponseWriter, r *http.Request) {
data, err := p.getTemplateData(w, r)
Expand Down
1 change: 0 additions & 1 deletion tmpl/style.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ textarea {
width: 80%;
height: 20em;
}

.probe_result {
width: 1em;
height: 1em;
Expand Down

0 comments on commit 7b61506

Please sign in to comment.