-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance the devtools live reload HTTP vs HTTPS port change to be conf…
…iguration driven Fixes #36
- Loading branch information
1 parent
1933d1b
commit 994a1c9
Showing
5 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/digitalsanctuary/spring/user/util/LiveReloadGlobalControllerAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.digitalsanctuary.spring.user.util; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
|
||
/** | ||
* Provides a global advice for controllers to include LiveReload configuration details. | ||
* <p> | ||
* This advice will make the LiveReload port available to all controllers and views in the application. It is used on the layout.html template to | ||
* include the LiveReload script in dev and local environments. | ||
* </p> | ||
* | ||
* @author Devon Hillard | ||
*/ | ||
@ControllerAdvice | ||
public class LiveReloadGlobalControllerAdvice { | ||
|
||
/** | ||
* Flag to determine if the application is being accessed over HTTPS. | ||
*/ | ||
@Value("${spring.devtools.livereload.https:false}") | ||
private boolean isHttps; | ||
|
||
/** | ||
* Provides the appropriate LiveReload port based on the application's protocol. | ||
* <p> | ||
* If the application is running over HTTPS, the port will be {@code 35739}. Otherwise, it will be {@code 35729}. | ||
* </p> | ||
* | ||
* @return The appropriate LiveReload port. | ||
*/ | ||
@ModelAttribute("liveReloadPort") | ||
public int liveReloadPort() { | ||
return isHttps ? 35739 : 35729; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters