Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed Feb 19, 2025
1 parent 4f0bc89 commit cc2a9b7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
5 changes: 2 additions & 3 deletions otoroshi/app/next/plugins/cors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,10 @@ class Cors extends NgRequestTransformer with NgPreRouting {
ctx: NgTransformerErrorContext
)(implicit env: Env, ec: ExecutionContext, mat: Materializer): Future[NgPluginHttpResponse] = {
val req = ctx.request

val cors = ctx.cachedConfig(internalName)(configReads).getOrElse(NgCorsSettings())
val cors =
CorsSettings.fromJson(ctx.config).getOrElse(CorsSettings()).copy(enabled = true, excludedPatterns = Seq.empty)

val corsHeaders = cors
.legacy
.asHeaders(req)
.filter(t => t._1.trim.nonEmpty && t._2.trim.nonEmpty)
.map(v =>
Expand Down
1 change: 0 additions & 1 deletion otoroshi/app/next/plugins/headers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class OverrideHost extends NgRequestTransformer {
env
)
val headers = ctx.otoroshiRequest.headers.-("Host").-("host").+("Host" -> host)

val request = ctx.otoroshiRequest.copy(headers = headers)
Right(request)
}
Expand Down
8 changes: 8 additions & 0 deletions otoroshi/app/next/plugins/zip.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class ZipFileBackend extends NgBackendCall {
private def atPath(_path: String, zip: ZipFile, config: ZipFileBackendConfig)(implicit
env: Env
): Option[(String, Source[ByteString, _])] = {

var path =
if (_path == "/") "index.html"
else {
Expand All @@ -143,6 +144,13 @@ class ZipFileBackend extends NgBackendCall {
if (path.startsWith("/")) {
path = path.substring(1)
}

val entries = zip.entries()
while (entries.hasMoreElements) {
val entry = entries.nextElement
System.out.println(entry.getName)
}

Option(zip.getEntry(path)).flatMap { entry =>
if (entry.isDirectory) {
None
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit cc2a9b7

Please sign in to comment.