package api

import (
	"fr.latosa-escrima/api/blogs"
	"fr.latosa-escrima/core"
)

var BlogsRoutes = map[string]core.Handler{
	"/blogs": {
		Handler:     blogs.HandleGetBlogs,
		Middlewares: []core.Middleware{Methods("GET")},
	},
	"/blogs/new": {
		Handler: blogs.HandleNew,
		Middlewares: []core.Middleware{Methods(("POST")),
			HasPermissions("blogs", "insert"), AuthJWT}},
	"/blogs/categories": {
		Handler:     blogs.HandleCategories,
		Middlewares: []core.Middleware{Methods("GET")},
	},
	"/blogs/{identifier}": {
		Handler:     blogs.HandleBlog,
		Middlewares: []core.Middleware{Methods("GET")}},
	"/blogs/{blog_uuid}/delete": {
		Handler: blogs.HandleDelete,
		Middlewares: []core.Middleware{Methods("DELETE"),
			HasPermissions("blogs", "delete"), AuthJWT},
	},
	"/blogs/{blog_uuid}/update": {
		Handler: blogs.HandleUpdate,
		Middlewares: []core.Middleware{Methods("PATCH"),
			HasPermissions("blogs", "update"), AuthJWT},
	},
}
