diff --git a/.air.toml b/.air.toml
new file mode 100644
index 0000000..d35912f
--- /dev/null
+++ b/.air.toml
@@ -0,0 +1,52 @@
+root = "."
+testdata_dir = "testdata"
+tmp_dir = "tmp"
+
+[build]
+ args_bin = []
+ bin = "fibertest.exe"
+ cmd = "make build"
+ delay = 1000
+ exclude_dir = ["assets", "tmp", "vendor", "testdata"]
+ exclude_file = []
+ exclude_regex = ["_test.go"]
+ exclude_unchanged = false
+ follow_symlink = false
+ full_bin = ""
+ include_dir = []
+ include_ext = ["go", "tpl", "tmpl", "html", "css", "js"]
+ include_file = []
+ kill_delay = "0s"
+ log = "build-errors.log"
+ poll = false
+ poll_interval = 0
+ post_cmd = []
+ pre_cmd = []
+ rerun = false
+ rerun_delay = 500
+ send_interrupt = false
+ stop_on_error = false
+
+[color]
+ app = ""
+ build = "yellow"
+ main = "magenta"
+ runner = "green"
+ watcher = "cyan"
+
+[log]
+ main_only = false
+ silent = false
+ time = false
+
+[misc]
+ clean_on_exit = false
+
+[proxy]
+ app_port = 5001
+ enabled = true
+ proxy_port = 5002
+
+[screen]
+ clear_on_rebuild = false
+ keep_scroll = true
diff --git a/Makefile b/Makefile
index 2e6bfc1..c976969 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,10 @@ build:
go build .
docs:
- go tool godoc -http=localhost:6060 -index
+ go tool godoc -http=localhost:6060 -index -index_files godoc.idx
+
+build_docs:
+ go tool godoc -v -http=localhost:6060 -index -index_files godoc.idx -write_index
dev:
- air
+ go tool air
diff --git a/main.go b/main.go
index b758dd9..b489817 100644
--- a/main.go
+++ b/main.go
@@ -12,9 +12,9 @@ import (
type Link struct {
Id int `db:"id" json:"id"`
- StreamId int `db:"stream_id" json:"stream_id"`
- Url string `db:"url" json:"url"`
- Description string `db:"description" json:"description"`
+ StreamId int `db:"stream_id" json:"stream_id" form:"stream_id"`
+ Url string `db:"url" json:"url" form:"url"`
+ Description string `db:"description" json:"description" form:"description"`
}
type Stream struct {
@@ -74,13 +74,32 @@ func main() {
return GetJson[Stream](db, c, err, sql, args...)
})
-
app.Get("/api/stream/:id/links", func (c *fiber.Ctx) error {
sql, args, err := sq.Select("*").From("stream_link").Where("stream_id", c.Params("id")).ToSql()
return SelectJson[Link](db, c, err, sql, args...)
})
+ app.Post("/api/link", func (c *fiber.Ctx) error {
+ link := new(Link)
+
+ if err := c.BodyParser(link); err != nil {
+ log.Println(err);
+ return c.Redirect("/live/")
+ }
+
+ sql, args, err := sq.Insert("stream_link").Columns("stream_id", "url", "description").Values(link.StreamId, link.Url, link.Description).ToSql()
+
+ if err != nil {
+ log.Println(err)
+ return c.Redirect("/live/")
+ }
+
+ db.MustExec(sql, args...)
+
+ return c.Redirect("/live/")
+ })
+
app.Static("/", "./public")
log.Fatal(app.Listen(":5001"))
diff --git a/public/live/index.html b/public/live/index.html
index 5416c83..235a9f3 100644
--- a/public/live/index.html
+++ b/public/live/index.html
@@ -9,7 +9,8 @@
@@ -26,8 +27,8 @@
Links Found in Chat
-