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

com.healthlx.smartonfhir.core.RequestContextUtil Maven / Gradle / Ivy

Go to download

Library that makes it easy to start developing an app using SMART App Launch Framework.

There is a newer version: 0.3.6
Show newest version
package com.healthlx.smartonfhir.core;

import org.springframework.util.Assert;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * Utility class with simple methods to deal with {@link RequestContextHolder}.
 */
public final class RequestContextUtil {

  private RequestContextUtil() {}

  /**
   * Get the current request bound to the {@link RequestContextHolder} attributes.
   *
   * @return the current {@link HttpServletRequest} instance
   */
  public static HttpServletRequest getRequest() {
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    Assert.notNull(requestAttributes, "No RequestAttributes object is currently bound to the thread.");
    return ((ServletRequestAttributes) requestAttributes).getRequest();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy