25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.4KB

  1. <%
  2. Class ErrorController_Class
  3. Private m_useLayout
  4. Private Sub Class_Initialize()
  5. m_useLayout = True
  6. End Sub
  7. ' JSON API requests (/api/...) get JSON errors without the HTML layout
  8. Public Property Get useLayout
  9. If IsApiRequest() Then
  10. useLayout = False
  11. Else
  12. useLayout = m_useLayout
  13. End If
  14. End Property
  15. Private Function IsApiRequest()
  16. IsApiRequest = (LCase(Left(GetRequestPath(), 5)) = "/api/")
  17. End Function
  18. Public Property Let useLayout(v)
  19. m_useLayout = v
  20. End Property
  21. Public Sub Index()
  22. Response.Write "Index called"
  23. End Sub
  24. Public Sub NotFound()
  25. If IsApiRequest() Then
  26. Api_Error 404, "not_found", "No such endpoint."
  27. Exit Sub
  28. End If
  29. Response.Status = "404 Not Found"
  30. %>
  31. <!--#include file="../views/Error/NotFound.asp" -->
  32. <%
  33. End Sub
  34. ' The path exists, but not for this HTTP method (resolved by Router_Class.AllowedMethods)
  35. Public Sub MethodNotAllowed(allow)
  36. If IsApiRequest() Then
  37. Api_Error 405, "method_not_allowed", "Use one of: " & allow & "."
  38. Else
  39. Response.Status = "405 Method Not Allowed"
  40. Response.Write "<p>Method not allowed. Use one of: " & Server.HTMLEncode(allow) & ".</p>"
  41. End If
  42. Response.AddHeader "Allow", allow
  43. End Sub
  44. ' Static action dispatch (AxonASP mishandles runtime-built Eval/Execute calls),
  45. ' called through <Name>Controller_Invoke at the bottom of this file.
  46. Public Sub Invoke(actionName, args)
  47. Select Case LCase(actionName)
  48. Case "index" : Index
  49. Case "notfound" : NotFound
  50. Case "methodnotallowed" : MethodNotAllowed args(0)
  51. Case Else
  52. Err.Raise 438, "ErrorController_Class", "Action '" & actionName & "' not found"
  53. End Select
  54. End Sub
  55. End Class
  56. Dim ErrorController_Class__Singleton
  57. Function ErrorController()
  58. If IsEmpty(ErrorController_Class__Singleton) Then
  59. Set ErrorController_Class__Singleton = New ErrorController_Class
  60. End If
  61. Set ErrorController = ErrorController_Class__Singleton
  62. End Function
  63. ' Global entry point used by MVC_InvokeAction via GetRef. A separate call site per controller
  64. ' avoids AxonASP binding a shared call site to the first controller's Invoke.
  65. Sub ErrorController_Invoke(actionName, args)
  66. ErrorController().Invoke actionName, args
  67. End Sub
  68. %>

Powered by TurnKey Linux.