package handlers import ( "git.andreafazzi.eu/andrea/oef/config" ) const ( PermissionCreate = iota PermissionRead PermissionReadAll PermissionUpdate PermissionDelete CreateLabel = iota ReadAllLabel ReadLabel UpdateLabel DeleteLabel ) var ( 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}, } 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}, } }