diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-10-26 22:33:30 -0300 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | b97e0403c8f0be0bf415e537981763495ae0b783 (patch) | |
tree | c95f1879e0e8f075871372fece3f68b6c1b07ceb | |
parent | 48fefb76c0a908cc3fa00abc9c090ce3ac8cb560 (diff) |
move routes to subpackage
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | main.go | 138 | ||||
-rw-r--r-- | routes/actor.go | 57 | ||||
-rw-r--r-- | routes/admin.go | 39 | ||||
-rw-r--r-- | routes/boardmgmt.go | 47 | ||||
-rw-r--r-- | routes/follow.go | 15 | ||||
-rw-r--r-- | routes/inbox.go | 9 | ||||
-rw-r--r-- | routes/index.go | 7 | ||||
-rw-r--r-- | routes/media.go | 7 | ||||
-rw-r--r-- | routes/news.go | 7 | ||||
-rw-r--r-- | routes/outbox.go | 9 |
11 files changed, 233 insertions, 104 deletions
@@ -1,4 +1,4 @@ -module github.com/FChannel/Server +module github.com/FChannel0/FChannel-Server go 1.15 @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" + "github.com/FChannel0/FChannel-Server/routes" "github.com/gofiber/fiber/v2" "github.com/gofiber/template/html" // "github.com/gofrs/uuid" @@ -121,7 +122,8 @@ func main() { TemplateFunctions(template) app := fiber.New(fiber.Config{ - Views: template, + AppName: "FChannel", + Views: template, }) app.Static("/public", "./public") @@ -131,139 +133,69 @@ func main() { Main actor */ - app.Get("/", IndexGet) + app.Get("/", routes.Index) - app.Get("/inbox", func(c *fiber.Ctx) error { - return c.SendString("main inbox") - }) - - app.Get("/outbox", func(c *fiber.Ctx) error { - return c.SendString("main outbox") - }) + app.Get("/inbox", routes.Inbox) + app.Get("/outbox", routes.Outbox) - app.Get("/following", func(c *fiber.Ctx) error { - return c.SendString("main following") - }) - - app.Get("/followers", func(c *fiber.Ctx) error { - return c.SendString("main followers") - }) + app.Get("/following", routes.Following) + app.Get("/followers", routes.Followers) /* Board actor */ - app.Get("/:actor", OutboxGet) + app.Get("/:actor", routes.ActorIndex) //OutboxGet) - app.Get("/:actor/:post", PostGet) + app.Get("/:actor/:post", routes.ActorPostGet) + app.Get("/post", routes.ActorPost) - app.Get("/:actor/inbox", func(c *fiber.Ctx) error { - return c.SendString("actor inbox") - }) + app.Get("/:actor/inbox", routes.ActorInbox) + app.Get("/:actor/outbox", routes.ActorOutbox) - app.Get("/:actor/outbox", func(c *fiber.Ctx) error { - return c.SendString("actor outbox") - }) + app.Get("/:actor/following", routes.ActorFollowing) + app.Get("/:actor/followers", routes.ActorFollowers) - app.Get("/:actor/following", func(c *fiber.Ctx) error { - return c.SendString("actor following") - }) - - app.Get("/:actor/followers", func(c *fiber.Ctx) error { - return c.SendString("actor followers") - }) - - app.Get("/:actor/reported", func(c *fiber.Ctx) error { - return c.SendString("actor reported") - }) - - app.Get("/:actor/archive", func(c *fiber.Ctx) error { - return c.SendString("actor archive") - }) - - app.Get("/post", func(c *fiber.Ctx) error { - return c.SendString("actor post") - }) + app.Get("/:actor/reported", routes.ActorReported) + app.Get("/:actor/archive", routes.ActorArchive) /* Admin routes */ - app.Get("/verify", func(c *fiber.Ctx) error { - return c.SendString("admin verify") - }) + app.Get("/verify", routes.AdminVerify) - app.Get("/auth", func(c *fiber.Ctx) error { - return c.SendString("admin auth") - }) + app.Get("/auth", routes.AdminAuth) - app.Get("/"+*Key+"/", func(c *fiber.Ctx) error { - return c.SendString("admin key") - }) + app.Get("/"+*Key+"/", routes.AdminIndex) - app.Get("/"+*Key+"/addboard", func(c *fiber.Ctx) error { - return c.SendString("admin addboard ") - }) + app.Get("/"+*Key+"/addboard", routes.AdminAddBoard) - app.Get("/"+*Key+"/postnews", func(c *fiber.Ctx) error { - return c.SendString("admin post news") - }) - - app.Get("/"+*Key+"/newsdelete", func(c *fiber.Ctx) error { - return c.SendString("admin news delete") - }) - - app.Get("/news", func(c *fiber.Ctx) error { - return c.SendString("admin news") - }) + app.Get("/"+*Key+"/postnews", routes.AdminPostNews) + app.Get("/"+*Key+"/newsdelete", routes.AdminNewsDelete) + app.Get("/news", routes.NewsGet) /* Board managment */ - app.Get("/banmedia", func(c *fiber.Ctx) error { - return c.SendString("board ban media") - }) - - app.Get("/delete", func(c *fiber.Ctx) error { - return c.SendString("board delete") - }) - - app.Get("/deleteattach", func(c *fiber.Ctx) error { - return c.SendString("board delete attach") - }) - - app.Get("/marksensitive", func(c *fiber.Ctx) error { - return c.SendString("board mark sensitive") - }) + app.Get("/banmedia", routes.BoardBanMedia) + app.Get("/delete", routes.BoardDelete) - app.Get("/remove", func(c *fiber.Ctx) error { - return c.SendString("board remove") - }) - - app.Get("/removeattach", func(c *fiber.Ctx) error { - return c.SendString("Hello World") - }) + app.Get("/deleteattach", routes.BoardDeleteAttach) + app.Get("/marksensitive", routes.BoardMarkSensitive) - app.Get("/addtoindex", func(c *fiber.Ctx) error { - return c.SendString("board add to index") - }) + app.Get("/remove", routes.BoardRemove) + app.Get("/removeattach", routes.BoardRemoveAttach) - app.Get("/poparchive", func(c *fiber.Ctx) error { - return c.SendString("board pop archive") - }) + app.Get("/addtoindex", routes.BoardAddToIndex) - app.Get("/autosubscribe", func(c *fiber.Ctx) error { - return c.SendString("board autosubscribe") - }) + app.Get("/poparchive", routes.BoardPopArchive) - app.Get("/blacklist", func(c *fiber.Ctx) error { - return c.SendString("board blacklist") - }) + app.Get("/autosubscribe", routes.BoardAutoSubscribe) - app.Get("/report", func(c *fiber.Ctx) error { - return c.SendString("board report") - }) + app.Get("/blacklist", routes.BoardBlacklist) + app.Get("/report", routes.BoardBlacklist) app.Get("/.well-known/webfinger", func(c *fiber.Ctx) error { acct := c.Query("resource") diff --git a/routes/actor.go b/routes/actor.go new file mode 100644 index 0000000..7fc9cb5 --- /dev/null +++ b/routes/actor.go @@ -0,0 +1,57 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func ActorIndex(c *fiber.Ctx) error { + // STUB + // TODO: OutboxGet, already implemented + return c.SendString("actor index") +} + +func ActorPostGet(c *fiber.Ctx) error { + // STUB + // TODO: PostGet + return c.SendString("actor post") +} + +func ActorInbox(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor inbox") +} + +func ActorOutbox(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor outbox") +} + +func ActorFollowing(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor following") +} + +func ActorFollowers(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor followers") +} + +func ActorReported(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor reported") +} + +func ActorArchive(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor archive") +} + +func ActorPost(c *fiber.Ctx) error { + // STUB + + return c.SendString("actor post") +} diff --git a/routes/admin.go b/routes/admin.go new file mode 100644 index 0000000..068dda3 --- /dev/null +++ b/routes/admin.go @@ -0,0 +1,39 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func AdminVerify(c *fiber.Ctx) error { + // STUB + + return c.SendString("admin verify") +} + +func AdminAuth(c *fiber.Ctx) error { + // STUB + + return c.SendString("admin auth") +} + +func AdminIndex(c *fiber.Ctx) error { + // STUB + + return c.SendString("admin index") +} + +func AdminAddBoard(c *fiber.Ctx) error { + // STUB + + return c.SendString("admin add board") +} + +func AdminPostNews(c *fiber.Ctx) error { + // STUB + + return c.SendString("admin post news") +} + +func AdminNewsDelete(c *fiber.Ctx) error { + // STUB + + return c.SendString("admin news delete") +} diff --git a/routes/boardmgmt.go b/routes/boardmgmt.go new file mode 100644 index 0000000..12e133d --- /dev/null +++ b/routes/boardmgmt.go @@ -0,0 +1,47 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func BoardBanMedia(c *fiber.Ctx) error { + return c.SendString("board ban media") +} + +func BoardDelete(c *fiber.Ctx) error { + return c.SendString("board delete") +} + +func BoardDeleteAttach(c *fiber.Ctx) error { + return c.SendString("board delete attach") +} + +func BoardMarkSensitive(c *fiber.Ctx) error { + return c.SendString("board mark sensitive") +} + +func BoardRemove(c *fiber.Ctx) error { + return c.SendString("board remove") +} + +func BoardRemoveAttach(c *fiber.Ctx) error { + return c.SendString("board remove attach") +} + +func BoardAddToIndex(c *fiber.Ctx) error { + return c.SendString("board add to index") +} + +func BoardPopArchive(c *fiber.Ctx) error { + return c.SendString("board pop archive") +} + +func BoardAutoSubscribe(c *fiber.Ctx) error { + return c.SendString("board auto subscribe") +} + +func BoardBlacklist(c *fiber.Ctx) error { + return c.SendString("board blacklist") +} + +func BoardReport(c *fiber.Ctx) error { + return c.SendString("board report") +} diff --git a/routes/follow.go b/routes/follow.go new file mode 100644 index 0000000..2578983 --- /dev/null +++ b/routes/follow.go @@ -0,0 +1,15 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func Following(c *fiber.Ctx) error { + // STUB + + return c.SendString("main following") +} + +func Followers(c *fiber.Ctx) error { + // STUB + + return c.SendString("main followers") +} diff --git a/routes/inbox.go b/routes/inbox.go new file mode 100644 index 0000000..2f88329 --- /dev/null +++ b/routes/inbox.go @@ -0,0 +1,9 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func Inbox(c *fiber.Ctx) error { + // STUB + + return c.SendString("main inbox") +} diff --git a/routes/index.go b/routes/index.go new file mode 100644 index 0000000..ccd398b --- /dev/null +++ b/routes/index.go @@ -0,0 +1,7 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func Index(c *fiber.Ctx) error { + return c.SendString("index") +} diff --git a/routes/media.go b/routes/media.go new file mode 100644 index 0000000..a4543c1 --- /dev/null +++ b/routes/media.go @@ -0,0 +1,7 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func ApiMedia(c *fiber.Ctx) error { + return c.SendString("api media") +} diff --git a/routes/news.go b/routes/news.go new file mode 100644 index 0000000..585614d --- /dev/null +++ b/routes/news.go @@ -0,0 +1,7 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func NewsGet(c *fiber.Ctx) error { + return c.SendString("news get") +} diff --git a/routes/outbox.go b/routes/outbox.go new file mode 100644 index 0000000..8945bb1 --- /dev/null +++ b/routes/outbox.go @@ -0,0 +1,9 @@ +package routes + +import "github.com/gofiber/fiber/v2" + +func Outbox(c *fiber.Ctx) error { + // STUB + + return c.SendString("main outbox") +} |