admissionServer/routes.go
Marcel fa9d4c0fc6 Dodano metodę odczytującą dane z wskazanej tabeli w bazie.
Dodano polimorficzny interfejs aby odpowiedzialność za pobranie danych leżała po stronie elementu zależnego, a nie nadrzędnego.
Dodano metody rozszerzające do kolekcji modeli, które umożliwiają łatwe tworzenie modeli i dodawanie ich do kolekcji.
Pobieranie modeli jeszcze do poprawki.
2018-12-08 18:01:33 +01:00

34 lines
569 B
Go

package main
import (
"net/http"
"github.com/gorilla/mux"
)
type route struct {
Name string
Adres string
HandlerFunction http.HandlerFunc
}
type routes []route
var registredRoutes = routes{
route{"Index", "/", index},
route{"GetAll", "/getfromdb/{tableName}", getAll},
route{"GetOne", "/getfromdb/{primaryKey}", getIndex},
}
func newRouter() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
for _, r := range registredRoutes {
router.
Path(r.Adres).
Name(r.Name).
Handler(r.HandlerFunction)
}
return router
}