private static UriComponentsBuilder getBaseUrlToUse(@Nullable UriComponentsBuilder baseUrl) { return baseUrl == null ? ServletUriComponentsBuilder.fromCurrentServletMapping() : baseUrl.cloneBuilder(); }
private static String getPath() { UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentServletMapping(); String path = builder.build().getPath(); return path != null ? path : ""; }
private static UriComponentsBuilder getBaseUrlToUse(@Nullable UriComponentsBuilder baseUrl) { return baseUrl == null ? ServletUriComponentsBuilder.fromCurrentServletMapping() : baseUrl.cloneBuilder(); }
private static String getPath() { UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentServletMapping(); String path = builder.build().getPath(); return path != null ? path : ""; }
private static UriComponentsBuilder getBaseUrlToUse(UriComponentsBuilder baseUrl) { if (baseUrl != null) { return baseUrl.cloneBuilder(); } else { return ServletUriComponentsBuilder.fromCurrentServletMapping(); } }
private static UriComponentsBuilder initBaseUrl() { UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentServletMapping(); return UriComponentsBuilder.fromPath(builder.build().getPath()); }
/** * Generate a full URL of the service, mostly for use in templates. * @return the app URL * @see io.spring.initializr.metadata.InitializrConfiguration.Env#isForceSsl() */ protected String generateAppUrl() { ServletUriComponentsBuilder builder = ServletUriComponentsBuilder .fromCurrentServletMapping(); if (isForceSsl()) { builder.scheme("https"); } return builder.build().toString(); }
/** * Creates a new {@link BasicLinkBuilder} to link to the current servlet mapping. * * @return */ public static BasicLinkBuilder linkToCurrentMapping() { return new BasicLinkBuilder(ServletUriComponentsBuilder.fromCurrentServletMapping()); }
/** * Returns a new {@link UriComponentsBuilder} for the base URI. If the base URI is not absolute, it'll lokup the URI * for the current servlet mapping and extend it accordingly. * * @return */ public UriComponentsBuilder getUriComponentsBuilder() { if (baseUri.isAbsolute()) { return UriComponentsBuilder.fromUri(baseUri); } return ServletUriComponentsBuilder.fromCurrentServletMapping().path(baseUri.toString()); } }
/** * Returns the href for the {@link Curie} instance to be created. Will prepend the current application URI (servlet * mapping) in case the template is not an absolute one in the first place. * * @param name will never be {@literal null} or empty. * @param template will never be {@literal null}. * @return the {@link String} to be used as href in the {@link Curie} to be created, must not be {@literal null}. */ protected String getCurieHref(String name, UriTemplate template) { if (template.toString().startsWith("http")) { return template.toString(); } String applicationUri = ServletUriComponentsBuilder.fromCurrentServletMapping().build().expand().toString(); return applicationUri.concat(template.toString()); }
/** * Creates a new {@link BasicLinkBuilder} to link to the current servlet mapping. * * @return */ public static BasicLinkBuilder linkToCurrentMapping() { return new BasicLinkBuilder(ServletUriComponentsBuilder.fromCurrentServletMapping()); }
private static UriComponentsBuilder getBaseUrlToUse(UriComponentsBuilder baseUrl) { if (baseUrl != null) { return baseUrl.cloneBuilder(); } else { return ServletUriComponentsBuilder.fromCurrentServletMapping(); } }
/** * Returns a new {@link UriComponentsBuilder} for the base URI. If the base URI is not absolute, it'll lokup the URI * for the current servlet mapping and extend it accordingly. * * @return */ public UriComponentsBuilder getUriComponentsBuilder() { if (baseUri.isAbsolute()) { return UriComponentsBuilder.fromUri(baseUri); } return ServletUriComponentsBuilder.fromCurrentServletMapping().path(baseUri.toString()); } }
@RequestMapping(path = "/workbooks/{workbookId}/comments", method = RequestMethod.POST) public @ResponseBody ResponseEntity<?> createComments(@PathVariable("workbookId") String workbookId, @RequestBody Comment comment) { comment.setDomainType(WORKBOOK); comment.setDomainId(workbookId); commentRepository.saveAndFlush(comment); final URI location = ServletUriComponentsBuilder .fromCurrentServletMapping().path("/api/workbooks/{workbookId}/comments/{commentId}").build() .expand(workbookId, comment.getId()).toUri(); return ResponseEntity.created(location).build(); }
/** Extracts the base URL from current request */ public static RestUrlBuilder fromCurrentRequest() { return usingBaseUrl(ServletUriComponentsBuilder.fromCurrentServletMapping().build().toUriString()); } }
/** Extracts the base URL from current request */ public static ContentRestUrlBuilder fromCurrentRequest() { return usingBaseUrl(ServletUriComponentsBuilder.fromCurrentServletMapping().build().toUriString()); } }
/** Extracts the base URL from current request */ public static RestUrlBuilder fromCurrentRequest() { return usingBaseUrl(ServletUriComponentsBuilder.fromCurrentServletMapping().build().toUriString()); } }
/** Extracts the base URL from current request */ public static RestUrlBuilder fromCurrentRequest() { return usingBaseUrl(ServletUriComponentsBuilder.fromCurrentServletMapping().build().toUriString()); } }
/** * Creates a new {@link JaxRsLinkBuilder} instance to link to the {@link Path} mapping tied to the given class binding * the given parameters to the URI template. * * @param resourceType the class to discover the annotation on, must not be {@literal null}. * @param parameters additional parameters to bind to the URI template declared in the annotation, must not be * {@literal null}. * @return */ public static JaxRsLinkBuilder linkTo(Class<?> resourceType, Object... parameters) { Assert.notNull(resourceType, "Controller type must not be null!"); Assert.notNull(parameters, "Parameters must not be null!"); UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(DISCOVERER.getMapping(resourceType)); UriComponents expandedComponents = HANDLER.expandAndEncode(builder, parameters); return new JaxRsLinkBuilder(ServletUriComponentsBuilder.fromCurrentServletMapping())// .slash(expandedComponents, true); }
/** * Returns the href for the {@link Curie} instance to be created. Will prepend the current application URI (servlet * mapping) in case the template is not an absolute one in the first place. * * @param name will never be {@literal null} or empty. * @param template will never be {@literal null}. * @return the {@link String} to be used as href in the {@link Curie} to be created, must not be {@literal null}. */ protected String getCurieHref(String name, UriTemplate template) { if (template.toString().startsWith("http")) { return template.toString(); } String applicationUri = ServletUriComponentsBuilder.fromCurrentServletMapping().build().expand().toString(); return applicationUri.concat(template.toString()); }