Skip to content

Commit

Permalink
Add a less confusing non-existent response for public resources
Browse files Browse the repository at this point in the history
  • Loading branch information
hugithordarson committed Feb 25, 2024
1 parent 765b1cf commit b248775
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ng-appserver/src/main/java/ng/appserver/NGApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ private NGResponse noHandlerResponse( final NGRequest request ) {
}

final Optional<byte[]> resourceBytes = resourceManager().bytesForPublicResourceNamed( resourcePath );

// FIXME: Shouldn't we allow the user to customize the response for a non-existent resource? // Hugi 2024-02-05
if( resourceBytes.isEmpty() ) {
final NGResponse errorResponse = new NGResponse( "public resource '" + resourcePath + "' does not exist", 404 );
errorResponse.setHeader( "content-type", "text/html" );
return errorResponse;
}

return NGResourceRequestHandler.responseForResource( resourceBytes, resourcePath );
}

Expand Down

0 comments on commit b248775

Please sign in to comment.