#408 - Polishing.

Original pull-request: #410.
Related issues: #330, #143, #516.
This commit is contained in:
Oliver Gierke
2017-07-27 19:04:50 +02:00
parent b346366f73
commit af3ec1a242
3 changed files with 30 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -17,15 +17,15 @@ package org.springframework.hateoas.mvc;
import static org.springframework.util.StringUtils.*;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Delegate;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Delegate;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.TemplateVariables;
import org.springframework.hateoas.core.AnnotationMappingDiscoverer;
@@ -53,7 +53,7 @@ import org.springframework.web.util.UriTemplate;
* @author Kevin Conaway
* @author Andrew Naydyonock
* @author Oliver Trosien
* @author Greg Turnquist
* @author Greg Turnquist
*/
public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuilder> {
@@ -257,18 +257,17 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
/**
* Returns a {@link UriComponentsBuilder} obtained from the current servlet mapping with scheme tweaked in case the
* request contains an {@code X-Forwarded-Ssl} header, which is not (yet) supported by the underlying
* {@link UriComponentsBuilder}.
*
* If no {@link RequestContextHolder} exists (you're outside a Spring Web call), fall back to relative URIs.
* {@link UriComponentsBuilder}. If no {@link RequestContextHolder} exists (you're outside a Spring Web call), fall
* back to relative URIs.
*
* @return
*/
static UriComponentsBuilder getBuilder() {
if (RequestContextHolder.getRequestAttributes() == null) {
return UriComponentsBuilder.fromPath("/");
}
if (RequestContextHolder.getRequestAttributes() == null) {
return UriComponentsBuilder.fromPath("/");
}
HttpServletRequest request = getCurrentRequest();
UriComponentsBuilder builder = ServletUriComponentsBuilder.fromServletMapping(request);