-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-22 Initialize reactive-netty implementation of http server
- Loading branch information
Showing
13 changed files
with
130 additions
and
95 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
31 changes: 31 additions & 0 deletions
31
src/main/java/org/panda_lang/reposilite/ReposiliteReactiveHttpServer.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,31 @@ | ||
package org.panda_lang.reposilite; | ||
|
||
import org.panda_lang.reposilite.config.Configuration; | ||
import reactor.core.publisher.Mono; | ||
import reactor.netty.DisposableServer; | ||
import reactor.netty.http.server.HttpServer; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
final class ReposiliteReactiveHttpServer { | ||
|
||
private final Reposilite reposilite; | ||
|
||
ReposiliteReactiveHttpServer(Reposilite reposilite) { | ||
this.reposilite = reposilite; | ||
} | ||
|
||
DisposableServer start(Configuration configuration) { | ||
return HttpServer.create() | ||
.bindAddress(() -> InetSocketAddress.createUnresolved(configuration.getHostname(), configuration.getPort() + 1)) | ||
.route(routes -> routes | ||
.get("/", (request, response) -> response.sendString(Mono.just(reposilite.getFrontend().forMessage("#onlypanda")))) | ||
.get("/*", (request, response) -> response) | ||
.head("/*", (request, response) -> response) | ||
.post("/*", (request, response) -> response) | ||
) | ||
.bindNow(); | ||
//.bindUntilJavaShutdown(Duration.ZERO, onStart); | ||
} | ||
|
||
} |
73 changes: 0 additions & 73 deletions
73
src/main/java/org/panda_lang/reposilite/ReposiliteWorkspace.java
This file was deleted.
Oops, something went wrong.
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
45 changes: 45 additions & 0 deletions
45
src/main/java/org/panda_lang/reposilite/config/ConfigurationLoader.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,45 @@ | ||
/* | ||
* Copyright (c) 2020 Dzikoysk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.panda_lang.reposilite.config; | ||
|
||
import org.panda_lang.reposilite.Reposilite; | ||
import org.panda_lang.reposilite.ReposiliteConstants; | ||
import org.panda_lang.reposilite.utils.FilesUtils; | ||
import org.panda_lang.reposilite.utils.YamlUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public final class ConfigurationLoader { | ||
|
||
public Configuration load() throws IOException { | ||
File configurationFile = new File(ReposiliteConstants.CONFIGURATION_FILE_NAME); | ||
|
||
if (!configurationFile.exists()) { | ||
Reposilite.getLogger().info("Generating default configuration file."); | ||
FilesUtils.copyResource("/reposilite.yml", ReposiliteConstants.CONFIGURATION_FILE_NAME); | ||
} | ||
else { | ||
Reposilite.getLogger().info("Using an existing configuration file"); | ||
} | ||
|
||
Reposilite.getLogger().info(""); | ||
return YamlUtils.load(configurationFile, Configuration.class); | ||
} | ||
|
||
|
||
} |
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
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