23 lines
596 B
Go
23 lines
596 B
Go
|
|
package httpapi
|
||
|
|
|
||
|
|
import (
|
||
|
|
"database/sql"
|
||
|
|
hres "form-builder-be-go/internal/hal"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/raff/halgo"
|
||
|
|
)
|
||
|
|
|
||
|
|
func RegisterRoot(r *gin.Engine, db *sql.DB) {
|
||
|
|
r.GET("/", func(c *gin.Context) {
|
||
|
|
root := hres.New("/")
|
||
|
|
root.AddCurie()
|
||
|
|
root.AddLink("sakila:actors", halgo.Link{Href: "/actors"})
|
||
|
|
root.AddLink("sakila:films", halgo.Link{Href: "/films"})
|
||
|
|
root.AddLink("sakila:languages", halgo.Link{Href: "/languages"})
|
||
|
|
root.AddLink("sakila:categories", halgo.Link{Href: "/categories"})
|
||
|
|
c.Header("Content-Type", "application/hal+json")
|
||
|
|
c.JSON(200, root)
|
||
|
|
})
|
||
|
|
}
|