All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grails.rest.render.RenderContext.groovy Maven / Gradle / Ivy

/*
 * Copyright 2013-2023 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package grails.rest.render

import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus

import grails.web.mime.MimeType

/**
 * Passed to a renderer to provide context information
 *
 * @author Graeme Rocher
 * @since 2.3
 */
interface RenderContext {

    /**
     * Which properties should be included in rendering
     * @return A list of includes
     */
    List getIncludes()

    /**
     * Which properties should be excluded from rendering
     * @return A list of excludes
     */
    List getExcludes()

    /**
     * @return Arguments passed by the user
     */
    Map getArguments()

    /**
     * @return The path the the resource
     */
    String getResourcePath()

    /**
     * @return Returns the mime type accepted by the client or null if non specified
     */
    MimeType getAcceptMimeType()

    /**
     * @return The locale
     */
    Locale getLocale()

    /**
     * @return The writer to render to
     */
    Writer getWriter()

    /**
     * @return The HTTP method
     */
    HttpMethod getHttpMethod();

    /**
     * @param status The status to set
     */
    void setStatus(HttpStatus status)

    /**
     * Sets the content type of the rendered response
     *
     * @param contentType The content type
     */
    void setContentType(String contentType)

    /**
     * The view to use for the response
     *
     * @param viewName The view name
     */
    void setViewName(String viewName)

    /**
     * @return The view name to use
     */
    String getViewName()

    /**
     * @return The default view name to use
     */
    String getDefaultViewName()

    /**
     * The model to use for the response
     * @param model The model
     */
    void setModel(Map model)

    /**
     * @return The current action name
     */
    String getActionName()

    /**
     * @return The current controller name
     */
    String getControllerName()

    /**
     * @return The current controller name
     */
    String getControllerNamespace()

    /**
     * Returns true if the getWriter() method was called
     */
    boolean wasWrittenTo()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy