25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

107 satır
3.5KB

  1. <%@ Language="VBScript" %>
  2. <% Option Explicit %>
  3. <%
  4. ' This test app owns its bootstrap and explicitly selects only the test route
  5. ' set in the shared framework. Production's bootstrap selects "production".
  6. ' Keeping this value inside each app prevents direct Default.asp?route=...
  7. ' requests from crossing the application boundary.
  8. Dim route, httpMethod, logDir, viewsDir, dbConnStringPath, dbConnStringFso, dbConnectionString, ctx, app, applicationName, statusLine, contentType, body, allowHeader
  9. route = Request.QueryString("route")
  10. httpMethod = Request.ServerVariables("REQUEST_METHOD")
  11. applicationName = "tests"
  12. ' logs/ and Views/ deliberately live outside the served "public" webroot (IIS
  13. ' site physical path = public/), so parent-relative MapPath is required here -
  14. ' requires enableParentPaths=true for this site. See docs/DECISIONS.md.
  15. logDir = Server.MapPath("../logs")
  16. viewsDir = Server.MapPath("../Views")
  17. ' db.connectionstring holds the live DB credentials and is never committed
  18. ' (see .gitignore, docs/DECISIONS.md) - read as plain framework wiring here,
  19. ' same as logDir/viewsDir, never hardcoded into any tracked file. Optional:
  20. ' an empty string means it isn't provisioned on this deployment. Unlike
  21. ' logs/ (each site has its own), there is exactly one shared credential file
  22. ' at the project root - test-app/public/ is two levels below the project
  23. ' root (root -> test-app -> public), one level deeper than production's
  24. ' public/ (root -> public), so it needs "../../" not "../" to reach it.
  25. dbConnStringPath = Server.MapPath("../../db.connectionstring")
  26. dbConnectionString = ""
  27. On Error Resume Next
  28. Set dbConnStringFso = Server.CreateObject("Scripting.FileSystemObject")
  29. If dbConnStringFso.FileExists(dbConnStringPath) Then
  30. dbConnectionString = Trim(dbConnStringFso.OpenTextFile(dbConnStringPath, 1).ReadAll)
  31. End If
  32. Set dbConnStringFso = Nothing
  33. Err.Clear
  34. On Error Goto 0
  35. Set ctx = Nothing
  36. On Error Resume Next
  37. Set ctx = Server.CreateObject("WscMvc.RequestContext")
  38. If Err.Number <> 0 Then
  39. Err.Clear
  40. On Error Goto 0
  41. Response.Status = "500 Internal Server Error"
  42. Response.ContentType = "text/plain; charset=utf-8"
  43. Response.Write "Internal Server Error"
  44. Response.End
  45. End If
  46. On Error Goto 0
  47. On Error Resume Next
  48. ctx.Initialize route, httpMethod, logDir
  49. If Err.Number <> 0 Then
  50. Err.Clear
  51. On Error Goto 0
  52. Set ctx = Nothing
  53. Response.Status = "500 Internal Server Error"
  54. Response.ContentType = "text/plain; charset=utf-8"
  55. Response.Write "Internal Server Error"
  56. Response.End
  57. End If
  58. On Error Goto 0
  59. Set app = Nothing
  60. On Error Resume Next
  61. Set app = Server.CreateObject("WscMvc.Application")
  62. If Err.Number <> 0 Then
  63. Err.Clear
  64. On Error Goto 0
  65. Set ctx = Nothing
  66. Response.Status = "500 Internal Server Error"
  67. Response.ContentType = "text/plain; charset=utf-8"
  68. Response.Write "Internal Server Error"
  69. Response.End
  70. End If
  71. On Error Goto 0
  72. statusLine = ""
  73. contentType = ""
  74. body = ""
  75. allowHeader = ""
  76. On Error Resume Next
  77. app.Run ctx, applicationName, viewsDir, dbConnectionString, statusLine, contentType, body, allowHeader
  78. If Err.Number <> 0 Then
  79. Err.Clear
  80. On Error Goto 0
  81. Set app = Nothing
  82. Set ctx = Nothing
  83. Response.Status = "500 Internal Server Error"
  84. Response.ContentType = "text/plain; charset=utf-8"
  85. Response.Write "Internal Server Error"
  86. Response.End
  87. End If
  88. On Error Goto 0
  89. Response.Status = statusLine
  90. Response.ContentType = contentType
  91. If Len(allowHeader) > 0 Then
  92. Response.AddHeader "Allow", allowHeader
  93. End If
  94. Response.Write body
  95. Set app = Nothing
  96. Set ctx = Nothing
  97. %>

Powered by TurnKey Linux.