summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/health/controller.go14
-rw-r--r--app/controllers/sparkles/controller.go27
2 files changed, 41 insertions, 0 deletions
diff --git a/app/controllers/health/controller.go b/app/controllers/health/controller.go
new file mode 100644
index 0000000..e241885
--- /dev/null
+++ b/app/controllers/health/controller.go
@@ -0,0 +1,14 @@
+package health
+
+import "net/http"
+
+type Controller struct {
+}
+
+func New() *Controller {
+ return &Controller{}
+}
+
+func (c *Controller) Index(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(http.StatusOK)
+}
diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go
new file mode 100644
index 0000000..365184f
--- /dev/null
+++ b/app/controllers/sparkles/controller.go
@@ -0,0 +1,27 @@
+package sparkles
+
+import (
+ "net/http"
+
+ "github.com/xlgmokha/x/pkg/serde"
+ "gitlab.com/mokhax/sparkled/pkg/db"
+ "gitlab.com/mokhax/sparkled/pkg/domain"
+)
+
+type Controller struct {
+ db db.Repository
+}
+
+func New(db db.Repository) *Controller {
+ return &Controller{db: db}
+}
+
+func (c *Controller) Index(w http.ResponseWriter, r *http.Request) {
+ serde.ToHTTP(w, r, c.db.All())
+}
+
+func (c *Controller) Create(w http.ResponseWriter, r *http.Request) {
+ sparkle, _ := serde.FromHTTP[*domain.Sparkle](r)
+ c.db.Save(sparkle)
+ w.WriteHeader(http.StatusCreated)
+}