-
Notifications
You must be signed in to change notification settings - Fork 7
Hello World
What would a wiki be, without a 'Hello World!' example? Rhetorical questions aside, this is how you achieve the outputting of such marvelous text in Kvantum:
First you'll need to add Kvantum as a dependency to your project. We recommend using either Gradle or Maven, but it's entirely up to you. If you need help doing that, then you can read Getting Started
Secondly, you'll need to create your own launcher class. Everything after that point depends on your needs.
package your.package;
import com.github.intellectualsites.kvantum.api.core.Kvantum;
import com.github.intellectualsites.kvantum.api.util.RequestManager;
import java.io.File;
import java.util.Optional;
public class HelloWorld
{
public static void main(final String[] args)
{
final ServerContext serverContext = ServerContext.builder()
.standalone( true )
.coreFolder( new File( "./HelloWorld" ) )
.logWrapper( new DefaultLogWrapper() )
.router( RequestManager.builder().build() ).build();
final Optional<Kvantum> serverOptional = serverContext.create();
if ( !serverOptional.isPresent() )
{
System.out.println( "Failed to start the server... Check terminal for information!" );
System.exit( -1 );
}
else
{
final Kvantum server = serverOptional.get();
server.createSimpleRequestHandler( "[file]", (request, response) -> response.setContent( "Hello World!" ) );
server.start();
}
}
}
This is just one of the methods you can use to generate a response via code. There is also an annotation-based system, and a OOP approach if that's more your style. We have tried to make the whole system as unlimited as possible, to suit every programmer and their preferred coding styles.
IntellectualServer
Files can be found in .kvantum/config
- Getting Started
- View Patterns
- File Patterns
- server.yml
views.yml- socketFilters.yml
- translations.yml
- SSL
- Getting Started
- Modules
- Hello World
- Plugins
- Events
- Account System
- Authorization
- Application System
- Sessions
- Create a view - OOP based
- Create a view - @Annotation based
- Middleware
- Extending Crush (Templating syntax)
- ViewReturn