go19.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // +build go1.9
  2. package iris
  3. import (
  4. "github.com/kataras/iris/context"
  5. "github.com/kataras/iris/core/host"
  6. "github.com/kataras/iris/core/router"
  7. )
  8. type (
  9. // Context is the midle-man server's "object" for the clients.
  10. //
  11. // A New context is being acquired from a sync.Pool on each connection.
  12. // The Context is the most important thing on the iris's http flow.
  13. //
  14. // Developers send responses to the client's request through a Context.
  15. // Developers get request information from the client's request by a Context.
  16. Context = context.Context
  17. // UnmarshalerFunc a shortcut, an alias for the `context#UnmarshalerFunc` type
  18. // which implements the `context#Unmarshaler` interface for reading request's body
  19. // via custom decoders, most of them already implement the `context#UnmarshalerFunc`
  20. // like the json.Unmarshal, xml.Unmarshal, yaml.Unmarshal and every library which
  21. // follows the best practises and is aligned with the Go standards.
  22. //
  23. // See 'context#UnmarshalBody` for more.
  24. //
  25. // Example: https://github.com/kataras/iris/blob/master/_examples/http_request/read-custom-via-unmarshaler/main.go
  26. UnmarshalerFunc = context.UnmarshalerFunc
  27. // A Handler responds to an HTTP request.
  28. // It writes reply headers and data to the Context.ResponseWriter() and then return.
  29. // Returning signals that the request is finished;
  30. // it is not valid to use the Context after or concurrently with the completion of the Handler call.
  31. //
  32. // Depending on the HTTP client software, HTTP protocol version,
  33. // and any intermediaries between the client and the iris server,
  34. // it may not be possible to read from the Context.Request().Body after writing to the context.ResponseWriter().
  35. // Cautious handlers should read the Context.Request().Body first, and then reply.
  36. //
  37. // Except for reading the body, handlers should not modify the provided Context.
  38. //
  39. // If Handler panics, the server (the caller of Handler) assumes that the effect of the panic was isolated to the active request.
  40. // It recovers the panic, logs a stack trace to the server error log, and hangs up the connection.
  41. Handler = context.Handler
  42. // A Map is a shortcut of the map[string]interface{}.
  43. Map = context.Map
  44. // Supervisor is a shortcut of the `host#Supervisor`.
  45. // Used to add supervisor configurators on common Runners
  46. // without the need of importing the `core/host` package.
  47. Supervisor = host.Supervisor
  48. // Party is just a group joiner of routes which have the same prefix and share same middleware(s) also.
  49. // Party could also be named as 'Join' or 'Node' or 'Group' , Party chosen because it is fun.
  50. //
  51. // Look the `core/router#APIBuilder` for its implementation.
  52. //
  53. // A shortcut for the `core/router#Party`, useful when `PartyFunc` is being used.
  54. Party = router.Party
  55. // ExecutionRules gives control to the execution of the route handlers outside of the handlers themselves.
  56. // Usage:
  57. // Party#SetExecutionRules(ExecutionRules {
  58. // Done: ExecutionOptions{Force: true},
  59. // })
  60. //
  61. // See `core/router/Party#SetExecutionRules` for more.
  62. // Example: https://github.com/kataras/iris/tree/master/_examples/mvc/middleware/without-ctx-next
  63. ExecutionRules = router.ExecutionRules
  64. // ExecutionOptions is a set of default behaviors that can be changed in order to customize the execution flow of the routes' handlers with ease.
  65. //
  66. // See `ExecutionRules` and `core/router/Party#SetExecutionRules` for more.
  67. ExecutionOptions = router.ExecutionOptions
  68. // CookieOption is the type of function that is accepted on
  69. // context's methods like `SetCookieKV`, `RemoveCookie` and `SetCookie`
  70. // as their (last) variadic input argument to amend the end cookie's form.
  71. //
  72. // Any custom or built'n `CookieOption` is valid,
  73. // see `CookiePath`, `CookieCleanPath`, `CookieExpires` and `CookieHTTPOnly` for more.
  74. //
  75. // An alias for the `context/Context#CookieOption`.
  76. CookieOption = context.CookieOption
  77. )