001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest.server.view.mustache; 018 019import org.apache.juneau.rest.server.*; 020import org.apache.juneau.rest.server.view.*; 021 022/** 023 * Child-resource flavor of the {@link MustacheMixin} mixin. 024 * 025 * <p> 026 * Mounts as a <b>routed child</b> via {@link Rest#children() @Rest(children=MustacheResource.class)} 027 * under a parent at the subtree {@code /mustache} and renders raw Mustache templates by delegating to a 028 * shared {@link MustacheDispatcher} worker — the same flavor-neutral {@link RawTemplateDispatcher} 029 * implementation the {@link MustacheMixin mixin} and {@link MustacheServlet servlet} flavors hold, so the 030 * three forms cannot drift. 031 * 032 * <h5 class='section'>See Also:</h5><ul> 033 * <li class='jc'>{@link MustacheMixin} 034 * <li class='jc'>{@link MustacheServlet} 035 * <li class='jc'>{@link ViewResource} 036 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/MustacheViewSupport">Mustache View Support</a> 037 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestServerComposition">REST Server — Mixins and Multi-Mount Paths</a> 038 * </ul> 039 * 040 * @since 10.0.0 041 */ 042@Rest( 043 path="/mustache", 044 responseProcessors={MustacheViewRenderer.class} 045) 046public class MustacheResource extends ViewResource { 047 048 private final MustacheDispatcher worker; 049 050 /** No-arg constructor — uses a default {@link MustacheDispatcher} worker. */ 051 public MustacheResource() { 052 this(MustacheDispatcher.create().build()); 053 } 054 055 /** 056 * Worker constructor. 057 * 058 * @param worker The shared flavor-neutral Mustache dispatcher this child delegates raw dispatch 059 * to. Must not be {@code null}. 060 */ 061 protected MustacheResource(MustacheDispatcher worker) { 062 this.worker = worker; 063 } 064 065 @Override /* ViewResource */ 066 protected RawTemplateDispatcher dispatcher() { 067 return worker; 068 } 069}