2016-05-17 08:59:34 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/FreifunkBremen/respond-collector/models"
|
2016-05-29 19:41:58 +00:00
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
"net/http"
|
2016-05-17 08:59:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ApiNodes struct {
|
2016-05-29 19:41:58 +00:00
|
|
|
config *models.Config
|
|
|
|
nodes *models.Nodes
|
2016-05-17 08:59:34 +00:00
|
|
|
}
|
|
|
|
|
2016-05-29 19:41:58 +00:00
|
|
|
func NewNodes(config *models.Config, router *httprouter.Router, prefix string, nodes *models.Nodes) {
|
2016-05-17 08:59:34 +00:00
|
|
|
api := &ApiNodes{
|
2016-05-29 19:41:58 +00:00
|
|
|
nodes: nodes,
|
2016-05-17 08:59:34 +00:00
|
|
|
config: config,
|
|
|
|
}
|
2016-05-29 19:41:58 +00:00
|
|
|
router.GET(prefix, api.GetAll)
|
2016-05-17 08:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (api *ApiNodes) GetAll(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
2016-05-29 19:41:58 +00:00
|
|
|
jsonOutput(w, r, api.nodes.List)
|
2016-05-17 08:59:34 +00:00
|
|
|
}
|