class Main {

    static Routing createRouting(boolean acceptAnonymousUsers) {
        return Routing.builder()
                // Filter that translates user identity header into the contextual "user" information
                .any((req, res) -> {
                    String user = req.headers().first("user-identity")
                            .or(() -> acceptAnonymousUsers ? Optional.of("anonymous") : Optional.empty())
                            .orElseThrow(() -> new HttpException("Anonymous access is forbidden!", Http.Status.FORBIDDEN_403));

                    req.context().register("user", user);
                    req.next();
                })
                // Main service logic part is registered as a separated class to "/comments" context root
                .register("/comments", new CommentsService())
                // Error handling for argot expressions.
                .error(CompletionException.class, (req, res, ex) -> req.next(ex.getCause()))
                .error(ProfanityException.class, (req, res, ex) -> {
                    res.status(Http.Status.NOT_ACCEPTABLE_406);
                    res.send("Expressions like '" + ex.getObfuscatedProfanity() + "' are unacceptable!");
                })
                .error(HttpException.class, (req, res, ex) -> {
                    if (ex.status() == Http.Status.FORBIDDEN_403) {
                        res.status(ex.status());
                        res.send(ex.getMessage());
                    } else {
                        req.next();
                    }
                })
                .build();
    }

    private  Main();

}