Skip to content

Commit

Permalink
Improve build and add gzip encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed May 21, 2024
1 parent 2815634 commit fd40892
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
23 changes: 14 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.nio.file.StandardCopyOption
import java.nio.file.Files
import java.text.SimpleDateFormat
import java.util.Date

Expand Down Expand Up @@ -117,6 +119,9 @@ tasks.shadowDistZip.setEnabled( false )
import java.nio.file.Files
task createDistributionFile( type: Zip ){
dependsOn startShadowScripts
doFirst {
delete archiveFile
}
from( 'build/scriptsShadow' ) {
into 'bin'
}
Expand All @@ -126,15 +131,15 @@ task createDistributionFile( type: Zip ){
}
archiveFileName = "boxlang-miniserver-${version}.zip"
doLast {
Files.copy( file( "build/libs/boxlang-miniserver-${version}-javadoc.jar" ).toPath(), file( "build/distributions/boxlang-miniserver-${version}-javadoc.jar" ).toPath() )

file( "build/evergreen" ).mkdirs()
if( branch == 'development' ){
Files.copy( file( "build/distributions/boxlang-miniserver-${version}.zip" ).toPath(), file( "build/evergreen/boxlang-miniserver-snapshot.zip" ).toPath() )
Files.copy( file( "build/distributions/boxlang-miniserver-${version}-all.jar" ).toPath(), file( "build/evergreen/boxlang-miniserver-snapshot-all.jar" ).toPath() )
} else {
Files.copy( file( "build/distributions/boxlang-miniserver-${version}.zip" ).toPath(), file( "build/evergreen/boxlang-miniserver-latest.zip" ).toPath() )
}
Files.copy( file( "build/libs/boxlang-miniserver-${version}-javadoc.jar" ).toPath(), file( "build/distributions/boxlang-miniserver-${version}-javadoc.jar" ).toPath(), StandardCopyOption.REPLACE_EXISTING )

file( "build/evergreen" ).mkdirs()
if( branch == 'development' ){
Files.copy( file( "build/distributions/boxlang-miniserver-${version}.zip" ).toPath(), file( "build/evergreen/boxlang-miniserver-snapshot.zip" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
Files.copy( file( "build/distributions/boxlang-miniserver-${version}-all.jar" ).toPath(), file( "build/evergreen/boxlang-miniserver-snapshot-all.jar" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
} else {
Files.copy( file( "build/distributions/boxlang-miniserver-${version}.zip" ).toPath(), file( "build/evergreen/boxlang-miniserver-latest.zip" ).toPath(), StandardCopyOption.REPLACE_EXISTING )
}

println "+ Distribution file has been created"
}
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/ortus/boxlang/web/MiniServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.predicate.Predicates;
import io.undertow.server.handlers.encoding.ContentEncodingRepository;
import io.undertow.server.handlers.encoding.EncodingHandler;
import io.undertow.server.handlers.encoding.GzipEncodingProvider;
import io.undertow.server.handlers.resource.PathResourceManager;
import io.undertow.server.handlers.resource.ResourceHandler;
import io.undertow.server.handlers.resource.ResourceManager;
Expand Down Expand Up @@ -119,16 +122,18 @@ public static void main( String[] args ) {
// Build out the server
Undertow BLServer = builder
.addHttpListener( port, host )
.setHandler( new WelcomeFileHandler(
Handlers.predicate(
// If this predicate evaluates to true, we process via BoxLang, otherwise, we serve a static file
Predicates.parse( "regex( '^(/.+?\\.cfml|/.+?\\.cf[cms]|.+?\\.bx[ms]{0,1})(/.*)?$' )" ),
new BLHandler( absWebRoot.toString() ),
new ResourceHandler( resourceManager )
.setDirectoryListingEnabled( true ) ),
resourceManager,
List.of( "index.bxm", "index.bxs", "index.cfm", "index.cfs", "index.htm", "index.html" )
) )
.setHandler( new EncodingHandler( new ContentEncodingRepository().addEncodingHandler(
"gzip", new GzipEncodingProvider(), 50, Predicates.parse( "request-larger-than(1500)" ) ) )
.setNext( new WelcomeFileHandler(
Handlers.predicate(
// If this predicate evaluates to true, we process via BoxLang, otherwise, we serve a static file
Predicates.parse( "regex( '^(/.+?\\.cfml|/.+?\\.cf[cms]|.+?\\.bx[ms]{0,1})(/.*)?$' )" ),
new BLHandler( absWebRoot.toString() ),
new ResourceHandler( resourceManager )
.setDirectoryListingEnabled( true ) ),
resourceManager,
List.of( "index.bxm", "index.bxs", "index.cfm", "index.cfs", "index.htm", "index.html" )
) ) )
.build();

// Add a shutdown hook to stop the server
Expand Down

0 comments on commit fd40892

Please sign in to comment.