- Generated SQL queries for actors, films, categories. - Introduced HTTP handlers for actor, film, and category endpoints. - Included utility functions for parsing query parameters and building URLs. - Enabled pagination, filtering, and HAL representation for responses.
22 lines
596 B
Go
22 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)
|
|
})
|
|
}
|