diff options
Diffstat (limited to '')
-rw-r--r-- | cmd/web/handlers.go | 13 | ||||
-rw-r--r-- | cmd/web/main.go | 2 | ||||
-rw-r--r-- | cmd/web/routes.go | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index b0e83ac..78d4029 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -10,6 +10,19 @@ import ( "github.com/yulqen/ded-go-core/internal/models" ) +func (app *application) listOperations(w http.ResponseWriter, r *http.Request) { + + ops, err := app.operations.ListAll() + if err != nil { + app.serverError(w, r, err) + return + } + + for _, op := range ops { + fmt.Fprintf(w, "%+v\n", op) + } +} + func (app *application) listOrganisation(w http.ResponseWriter, r *http.Request) { files := []string{ "./ui/html/base.tmpl.html", diff --git a/cmd/web/main.go b/cmd/web/main.go index cbfda5e..a8b8cb4 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -13,6 +13,7 @@ import ( type application struct { logger *slog.Logger + operations *models.OperationModel organisations *models.OrganisationModel } @@ -34,6 +35,7 @@ func main() { app := &application{ logger: logger, + operations: &models.OperationModel{DB: db}, organisations: &models.OrganisationModel{DB: db}, } diff --git a/cmd/web/routes.go b/cmd/web/routes.go index 23ecf7b..e21b25d 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -12,5 +12,6 @@ func (app *application) routes() *http.ServeMux { mux.HandleFunc("/organisation/list", app.listOrganisation) mux.HandleFunc("/organisation/view", app.organisationView) mux.HandleFunc("/organisation/create", app.organisationCreate) + mux.HandleFunc("/operation/list", app.listOperations) return mux } |