2020-01-16 12:47:35 +01:00
|
|
|
package handlers
|
|
|
|
|
2020-01-17 07:59:57 +01:00
|
|
|
import (
|
|
|
|
"git.andreafazzi.eu/andrea/oef/config"
|
|
|
|
)
|
|
|
|
|
2020-01-16 12:47:35 +01:00
|
|
|
const (
|
|
|
|
PermissionCreate = iota
|
|
|
|
PermissionRead
|
|
|
|
PermissionReadAll
|
|
|
|
PermissionUpdate
|
|
|
|
PermissionDelete
|
2020-01-17 07:59:57 +01:00
|
|
|
|
|
|
|
CreateLabel = iota
|
|
|
|
ReadAllLabel
|
|
|
|
ReadLabel
|
|
|
|
UpdateLabel
|
|
|
|
DeleteLabel
|
2020-01-16 12:47:35 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-01-17 07:59:57 +01:00
|
|
|
actions []string = []string{"Create", "ReadAll", "Read", "Update", "Delete"}
|
|
|
|
DefaultPathPatterns map[string]config.PathPattern
|
|
|
|
DefaultAPIPathPatterns map[string]config.PathPattern
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
DefaultPathPatterns = map[string]config.PathPattern{
|
|
|
|
actions[0]: config.PathPattern{"/%s/create/", "/%s/%d?format=html&tpl_layout=base&tpl_content=%s_show", []string{"GET", "POST"}, PermissionCreate},
|
|
|
|
actions[1]: config.PathPattern{"/%s", "", []string{"GET"}, PermissionReadAll},
|
|
|
|
actions[2]: config.PathPattern{"/%s/{id}", "", []string{"GET"}, PermissionRead},
|
|
|
|
actions[3]: config.PathPattern{"/%s/{id}/update", "/%s/%d?format=html&tpl_layout=base&tpl_content=%s_show", []string{"GET", "POST"}, PermissionUpdate},
|
|
|
|
actions[4]: config.PathPattern{"/%s/{id}/delete", "/%s?format=html&tpl_layout=base&tpl_content=%s", []string{"DELETE"}, PermissionDelete},
|
2020-01-16 12:47:35 +01:00
|
|
|
}
|
|
|
|
|
2020-01-17 07:59:57 +01:00
|
|
|
DefaultAPIPathPatterns = map[string]config.PathPattern{
|
|
|
|
actions[0]: config.PathPattern{"/api/%s/create/", "", []string{"GET", "POST"}, PermissionCreate},
|
|
|
|
actions[1]: config.PathPattern{"/api/%s", "", []string{"GET"}, PermissionReadAll},
|
|
|
|
actions[2]: config.PathPattern{"/api/%s/{id}", "", []string{"GET"}, PermissionRead},
|
|
|
|
actions[3]: config.PathPattern{"/api/%s/{id}/update", "", []string{"GET", "POST"}, PermissionUpdate},
|
|
|
|
actions[4]: config.PathPattern{"/api/%s/{id}/delete", "", []string{"DELETE"}, PermissionDelete},
|
2020-01-16 12:47:35 +01:00
|
|
|
}
|
2020-01-17 07:59:57 +01:00
|
|
|
}
|