summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@klarrio.com>2021-02-27 22:57:50 +0100
committerLibravatar tsmethurst <tobi.smethurst@klarrio.com>2021-02-27 22:57:50 +0100
commitfbf52fe84be071e90ea81e5f7951da2a1ece0dbf (patch)
treed2ebbef9a06a9b978c80fccfdc63deb99fb64db1 /internal/api
parentfirst commit (diff)
downloadgotosocial-fbf52fe84be071e90ea81e5f7951da2a1ece0dbf.tar.xz
messing around a bit
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/api.go11
-rw-r--r--internal/api/route_statuses.go13
-rw-r--r--internal/api/router.go36
3 files changed, 60 insertions, 0 deletions
diff --git a/internal/api/api.go b/internal/api/api.go
new file mode 100644
index 000000000..1c233705f
--- /dev/null
+++ b/internal/api/api.go
@@ -0,0 +1,11 @@
+package api
+
+// API is the API exposed to the outside world for access by front-ends; this is distinct from the federation API
+type API interface {
+
+}
+
+// api implements Api interface
+type api struct {
+
+}
diff --git a/internal/api/route_statuses.go b/internal/api/route_statuses.go
new file mode 100644
index 000000000..422f6292b
--- /dev/null
+++ b/internal/api/route_statuses.go
@@ -0,0 +1,13 @@
+package api
+
+import (
+ "net/http"
+
+ "github.com/gin-gonic/gin"
+)
+
+func statusGet(c *gin.Context) {
+ c.HTML(http.StatusOK, "index.tmpl", gin.H{
+ "title": "Posts",
+ })
+}
diff --git a/internal/api/router.go b/internal/api/router.go
new file mode 100644
index 000000000..3b0570779
--- /dev/null
+++ b/internal/api/router.go
@@ -0,0 +1,36 @@
+package api
+
+import "github.com/gin-gonic/gin"
+
+// Router provides the http routes used by the API
+type Router interface {
+ Route()
+}
+
+// NewRouter returns a new router
+func NewRouter() Router {
+ return &router{}
+}
+
+// router implements the router interface
+type router struct {
+
+}
+
+func (r *router) Route() {
+ ginRouter := gin.Default()
+ ginRouter.LoadHTMLGlob("web/template/*")
+
+ apiGroup := ginRouter.Group("/api")
+ {
+ v1 := apiGroup.Group("/v1")
+ {
+ statusesGroup := v1.Group("/statuses")
+ {
+ statusesGroup.GET(":id", statusGet)
+ }
+
+ }
+ }
+ ginRouter.Run()
+}