pub fn insert(&mut self, endpoint: ApiEndpoint) {
        let method = endpoint.method.clone();
        let path = endpoint.path.clone();

        let all_segments = path_to_segments(path.as_str());
        let mut varnames: BTreeSet<String> = BTreeSet::new();

        let mut node: &mut Box<HttpRouterNode> = &mut self.root;
        for raw_segment in all_segments {
            let segment = PathSegment::from(raw_segment);

            node = match segment {
                PathSegment::Literal(lit) => {
                    let edges = node.edges.get_or_insert(
                        HttpRouterEdges::Literals(BTreeMap::new()),
                    );
                    match edges {
                        /*
                         * We do not allow both literal and variable edges from
                         * the same node.  This could be supported (with some
                         * caveats about how matching would work), but it seems
                         * more likely to be a mistake.
                         */
                        HttpRouterEdges::Variable(varname, _) => {
                            panic!(
                                "URI path \"{}\": attempted to register route \
                                 for literal path segment \"{}\" when a route \
                                 exists for variable path segment (variable \
                                 name: \"{}\")",
                                path, lit, varname
                            );
                        }
                        HttpRouterEdges::Literals(ref mut literals) => literals
                            .entry(lit)
                            .or_insert_with(|| Box::new(HttpRouterNode::new())),
                    }
                }

                PathSegment::Varname(new_varname) => {
                    /*
                     * Do not allow the same variable name to be used more than
                     * once in the path.  Again, this could be supported (with
                     * some caveats), but it seems more likely to be a mistake.
                     */
                    if varnames.contains(&new_varname) {
                        panic!(
                            "URI path \"{}\": variable name \"{}\" is used \
                             more than once",
                            path, new_varname
                        );
                    }
                    varnames.insert(new_varname.clone());

                    let edges =
                        node.edges.get_or_insert(HttpRouterEdges::Variable(
                            new_varname.clone(),
                            Box::new(HttpRouterNode::new()),
                        ));
                    match edges {
                        /*
                         * See the analogous check above about combining literal
                         * and variable path segments from the same resource.
                         */
                        HttpRouterEdges::Literals(_) => panic!(
                            "URI path \"{}\": attempted to register route for \
                             variable path segment (variable name: \"{}\") \
                             when a route already exists for a literal path \
                             segment",
                            path, new_varname
                        ),

                        HttpRouterEdges::Variable(varname, ref mut node) => {
                            if *new_varname != *varname {
                                /*
                                 * Don't allow people to use different names for
                                 * the same part of the path.  Again, this could
                                 * be supported, but it seems likely to be
                                 * confusing and probably a mistake.
                                 */
                                panic!(
                                    "URI path \"{}\": attempted to use \
                                     variable name \"{}\", but a different \
                                     name (\"{}\") has already been used for \
                                     this",
                                    path, new_varname, varname
                                );
                            }

                            node
                        }
                    }
                }
            };
        }

        let methodname = method.as_str().to_uppercase();
        if node.methods.get(&methodname).is_some() {
            panic!(
                "URI path \"{}\": attempted to create duplicate route for \
                 method \"{}\"",
                path, method,
            );
        }

        node.methods.insert(methodname, endpoint);
    }
/**
     * Configure a route for HTTP requests based on the HTTP `method` and
     * URI `path`.  See the `HttpRouter` docs for information about how `path`
     * is processed.  Requests matching `path` will be resolved to `handler`.
     */
Configure a route for HTTP requests based on the HTTP `method` and
URI `path`.  See the `HttpRouter` docs for information about how `path`
is processed.  Requests matching `path` will be resolved to `handler`.
Configure a route for HTTP requests based on the HTTP ` method ` and URI ` path ` . See the ` HttpRouter ` docs for information about how ` path ` is processed . Requests matching ` path ` will be resolved to ` handler ` .
pub fn insert(&mut self, endpoint: ApiEndpoint) {
        let method = endpoint.method.clone();
        let path = endpoint.path.clone();
        let all_segments = path_to_segments(path.as_str());
        let mut varnames: BTreeSet<String> = BTreeSet::new();
        let mut node: &mut Box<HttpRouterNode> = &mut self.root;
        for raw_segment in all_segments {
            let segment = PathSegment::from(raw_segment);
            node = match segment {
                PathSegment::Literal(lit) => {
                    let edges = node.edges.get_or_insert(
                        HttpRouterEdges::Literals(BTreeMap::new()),
                    );
                    match edges {
                        /*
                         * We do not allow both literal and variable edges from
                         * the same node.  This could be supported (with some
                         * caveats about how matching would work), but it seems
                         * more likely to be a mistake.
                         */
                        HttpRouterEdges::Variable(varname, _) => {
                            panic!(
                                "URI path \"{}\": attempted to register route \
                                 for literal path segment \"{}\" when a route \
                                 exists for variable path segment (variable \
                                 name: \"{}\")",
                                path, lit, varname
                            );
                        }
                        HttpRouterEdges::Literals(ref mut literals) => literals
                            .entry(lit)
                            .or_insert_with(|| Box::new(HttpRouterNode::new())),
                    }
                }
                PathSegment::Varname(new_varname) => {
                    /*
                     * Do not allow the same variable name to be used more than
                     * once in the path.  Again, this could be supported (with
                     * some caveats), but it seems more likely to be a mistake.
                     */
                    if varnames.contains(&new_varname) {
                        panic!(
                            "URI path \"{}\": variable name \"{}\" is used \
                             more than once",
                            path, new_varname
                        );
                    }
                    varnames.insert(new_varname.clone());
                    let edges =
                        node.edges.get_or_insert(HttpRouterEdges::Variable(
                            new_varname.clone(),
                            Box::new(HttpRouterNode::new()),
                        ));
                    match edges {
                        /*
                         * See the analogous check above about combining literal
                         * and variable path segments from the same resource.
                         */
                        HttpRouterEdges::Literals(_) => panic!(
                            "URI path \"{}\": attempted to register route for \
                             variable path segment (variable name: \"{}\") \
                             when a route already exists for a literal path \
                             segment",
                            path, new_varname
                        ),
                        HttpRouterEdges::Variable(varname, ref mut node) => {
                            if *new_varname != *varname {
                                /*
                                 * Don't allow people to use different names for
                                 * the same part of the path.  Again, this could
                                 * be supported, but it seems likely to be
                                 * confusing and probably a mistake.
                                 */
                                panic!(
                                    "URI path \"{}\": attempted to use \
                                     variable name \"{}\", but a different \
                                     name (\"{}\") has already been used for \
                                     this",
                                    path, new_varname, varname
                                );
                            }
                            node
                        }
                    }
                }
            };
        }
        let methodname = method.as_str().to_uppercase();
        if node.methods.get(&methodname).is_some() {
            panic!(
                "URI path \"{}\": attempted to create duplicate route for \
                 method \"{}\"",
                path, method,
            );
        }
        node.methods.insert(methodname, endpoint);
    }
pub fn insert ( & mut self , endpoint : ApiEndpoint ) { let method = endpoint . method . clone ( ) ; let path = endpoint . path . clone ( ) ; let all_segments = path_to_segments ( path . as_str ( ) ) ; let mut varnames : BTreeSet < String > = BTreeSet :: new ( ) ; let mut node : & mut Box < HttpRouterNode > = & mut self . root ; for raw_segment in all_segments { let segment = PathSegment :: from ( raw_segment ) ; node = match segment { PathSegment :: Literal ( lit ) => { let edges = node . edges . get_or_insert ( HttpRouterEdges :: Literals ( BTreeMap :: new ( ) ) , ) ; match edges { /*
                         * We do not allow both literal and variable edges from
                         * the same node.  This could be supported (with some
                         * caveats about how matching would work), but it seems
                         * more likely to be a mistake.
                         */ HttpRouterEdges :: Variable ( varname , _ ) => { panic ! ( " \" \" \
 \" \" \
 \
 \" \" " path lit varname ) ; } HttpRouterEdges :: Literals ( ref mut literals ) => literals . entry ( lit ) . or_insert_with ( | | Box :: new ( HttpRouterNode :: new ( ) ) ) , } } PathSegment :: Varname ( new_varname ) => { /*
                     * Do not allow the same variable name to be used more than
                     * once in the path.  Again, this could be supported (with
                     * some caveats), but it seems more likely to be a mistake.
                     */ if varnames . contains ( & new_varname ) { panic ! ( " \" \" \" \" \
 " path new_varname ) ; } varnames . insert ( new_varname . clone ( ) ) ; let edges = node . edges . get_or_insert ( HttpRouterEdges :: Variable ( new_varname . clone ( ) , Box :: new ( HttpRouterNode :: new ( ) ) , ) ) ; match edges { /*
                         * See the analogous check above about combining literal
                         * and variable path segments from the same resource.
                         */ HttpRouterEdges :: Literals ( _ ) => panic ! ( " \" \" \
 \" \" \
 \
 " path new_varname ) , HttpRouterEdges :: Variable ( varname , ref mut node ) => { if * new_varname != * varname { /*
                                 * Don't allow people to use different names for
                                 * the same part of the path.  Again, this could
                                 * be supported, but it seems likely to be
                                 * confusing and probably a mistake.
                                 */ panic ! ( " \" \" \
 \" \" \
 \" \" \
 " path new_varname varname ) ; } node } } } } ; } let methodname = method . as_str ( ) . to_uppercase ( ) ; if node . methods . get ( & methodname ) . is_some ( ) { panic ! ( " \" \" \
 \" \" " path method ) ; } node . methods . insert ( methodname , endpoint ) ; }
Configure a route for HTTP requests based on the HTTP `method` and
 URI `path`.
Configure a route for HTTP requests based on the HTTP ` method ` and URI ` path ` .
&mut self
endpoint
ApiEndpoint
&mut self
endpoint
ApiEndpoint