messing around a bit
This commit is contained in:
11
internal/api/api.go
Normal file
11
internal/api/api.go
Normal file
@ -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 {
|
||||
|
||||
}
|
13
internal/api/route_statuses.go
Normal file
13
internal/api/route_statuses.go
Normal file
@ -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",
|
||||
})
|
||||
}
|
36
internal/api/router.go
Normal file
36
internal/api/router.go
Normal file
@ -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()
|
||||
}
|
Reference in New Issue
Block a user