From fbf52fe84be071e90ea81e5f7951da2a1ece0dbf Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Sat, 27 Feb 2021 22:57:50 +0100 Subject: messing around a bit --- internal/api/api.go | 11 +++++++++++ internal/api/route_statuses.go | 13 +++++++++++++ internal/api/router.go | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 internal/api/api.go create mode 100644 internal/api/route_statuses.go create mode 100644 internal/api/router.go (limited to 'internal/api') 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() +} -- cgit v1.2.3