Skip to main content

object_route

Function object_route 

Source
pub fn object_route(o: &Object) -> String
Expand description

The route of an object, from the object itself.

route asks for the kind and the identity separately, because the Cockpit’s router has those two strings out of a path and no object yet. This is the same function for every caller that is already holding the object, and it exists so that no consumer reaches for o.kind and o.identity and spells the address a second time.

use majordomus_cli::entity::{object_route, route};

let rule = object("rule", "project.entities-are-routable@1");
assert_eq!(
    object_route(&rule),
    "/cockpit/objects/rule/project-entities-are-routable-1"
);
// and it is the same address the router resolves with
assert_eq!(object_route(&rule), route(&rule.kind, &rule.identity));