-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(webUI): extracted web server initialization to dedicated class
Refs: #21
- Loading branch information
1 parent
e9e1ba1
commit 7c518bd
Showing
5 changed files
with
131 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024 Decision-Driven Development | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package ru.ewc.checklogic.server; | ||
|
||
import com.renomad.minum.web.RequestLine; | ||
import com.renomad.minum.web.WebFramework; | ||
|
||
/** | ||
* I am an interface for all the classes that define the endpoints for the web server. | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
interface Endpoints { | ||
/** | ||
* The shortcut to define an endpoint for a GET method. | ||
*/ | ||
RequestLine.Method GET = RequestLine.Method.GET; | ||
|
||
/** | ||
* The shortcut to define an endpoint for a POST method. | ||
*/ | ||
RequestLine.Method POST = RequestLine.Method.POST; | ||
|
||
/** | ||
* Register the endpoints with the web server. | ||
* | ||
* @param web The web framework to register endpoints in. | ||
*/ | ||
void register(WebFramework web); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024 Decision-Driven Development | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package ru.ewc.checklogic.server; | ||
|
||
import com.renomad.minum.web.FullSystem; | ||
import com.renomad.minum.web.WebFramework; | ||
import ru.ewc.checklogic.Computation; | ||
|
||
/** | ||
* I am the web server for the CheckLogic application. My main responsibility is to configure the | ||
* routes, initialize and start the server. | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
public final class WebServer { | ||
/** | ||
* The computation to be used for the web server. | ||
*/ | ||
private final Computation computation; | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param computation The computation to be used for the web server. | ||
*/ | ||
public WebServer(final Computation computation) { | ||
this.computation = computation; | ||
} | ||
|
||
public void start() { | ||
final FullSystem minum = FullSystem.initialize(); | ||
final WebFramework web = minum.getWebFramework(); | ||
registerEndpoints(web, new StatePage(this.computation)); | ||
registerEndpoints(web, new CommandPage(this.computation)); | ||
minum.block(); | ||
} | ||
|
||
private static void registerEndpoints(final WebFramework web, final Endpoints endpoints) { | ||
endpoints.register(web); | ||
} | ||
} |
7c518bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
9-76e7f501
disappeared fromsrc/main/java/ru/ewc/checklogic/server/StatePage.java
), that's why I closed #20. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.7c518bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
20-b050ce20
disappeared fromsrc/main/java/ru/ewc/checklogic/LogicChecker.java
), that's why I closed #21. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.