aliases.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. package iris
  2. import (
  3. "net/http"
  4. "path"
  5. "regexp"
  6. "github.com/kataras/iris/cache"
  7. "github.com/kataras/iris/context"
  8. "github.com/kataras/iris/core/handlerconv"
  9. "github.com/kataras/iris/core/host"
  10. "github.com/kataras/iris/core/router"
  11. "github.com/kataras/iris/hero"
  12. "github.com/kataras/iris/view"
  13. )
  14. type (
  15. // Context is the middle-man server's "object" for the clients.
  16. //
  17. // A New context is being acquired from a sync.Pool on each connection.
  18. // The Context is the most important thing on the iris's http flow.
  19. //
  20. // Developers send responses to the client's request through a Context.
  21. // Developers get request information from the client's request by a Context.
  22. Context = *context.Context
  23. // ViewEngine is an alias of `context.ViewEngine`.
  24. // See HTML, Blocks, Django, Jet, Pug, Ace, Handlebars, Amber and e.t.c.
  25. ViewEngine = context.ViewEngine
  26. // UnmarshalerFunc a shortcut, an alias for the `context#UnmarshalerFunc` type
  27. // which implements the `context#Unmarshaler` interface for reading request's body
  28. // via custom decoders, most of them already implement the `context#UnmarshalerFunc`
  29. // like the json.Unmarshal, xml.Unmarshal, yaml.Unmarshal and every library which
  30. // follows the best practises and is aligned with the Go standards.
  31. //
  32. // See 'context#UnmarshalBody` for more.
  33. //
  34. // Example: https://github.com/kataras/iris/blob/master/_examples/request-body/read-custom-via-unmarshaler/main.go
  35. UnmarshalerFunc = context.UnmarshalerFunc
  36. // A Handler responds to an HTTP request.
  37. // It writes reply headers and data to the Context.ResponseWriter() and then return.
  38. // Returning signals that the request is finished;
  39. // it is not valid to use the Context after or concurrently with the completion of the Handler call.
  40. //
  41. // Depending on the HTTP client software, HTTP protocol version,
  42. // and any intermediaries between the client and the iris server,
  43. // it may not be possible to read from the Context.Request().Body after writing to the context.ResponseWriter().
  44. // Cautious handlers should read the Context.Request().Body first, and then reply.
  45. //
  46. // Except for reading the body, handlers should not modify the provided Context.
  47. //
  48. // If Handler panics, the server (the caller of Handler) assumes that the effect of the panic was isolated to the active request.
  49. // It recovers the panic, logs a stack trace to the server error log, and hangs up the connection.
  50. Handler = context.Handler
  51. // Filter is just a type of func(Handler) bool which reports whether an action must be performed
  52. // based on the incoming request.
  53. //
  54. // See `NewConditionalHandler` for more.
  55. // An alias for the `context/Filter`.
  56. Filter = context.Filter
  57. // A Map is an alias of map[string]interface{}.
  58. Map = context.Map
  59. // Problem Details for HTTP APIs.
  60. // Pass a Problem value to `context.Problem` to
  61. // write an "application/problem+json" response.
  62. //
  63. // Read more at: https://github.com/kataras/iris/wiki/Routing-error-handlers
  64. //
  65. // It is an alias of the `context#Problem` type.
  66. Problem = context.Problem
  67. // ProblemOptions the optional settings when server replies with a Problem.
  68. // See `Context.Problem` method and `Problem` type for more details.
  69. //
  70. // It is an alias of the `context#ProblemOptions` type.
  71. ProblemOptions = context.ProblemOptions
  72. // JSON the optional settings for JSON renderer.
  73. //
  74. // It is an alias of the `context#JSON` type.
  75. JSON = context.JSON
  76. // ProtoMarshalOptions is a type alias for protojson.MarshalOptions.
  77. ProtoMarshalOptions = context.ProtoMarshalOptions
  78. // ProtoUnmarshalOptions is a type alias for protojson.UnmarshalOptions.
  79. ProtoUnmarshalOptions = context.ProtoUnmarshalOptions
  80. // XML the optional settings for XML renderer.
  81. //
  82. // It is an alias of the `context#XML` type.
  83. XML = context.XML
  84. // Supervisor is a shortcut of the `host#Supervisor`.
  85. // Used to add supervisor configurators on common Runners
  86. // without the need of importing the `core/host` package.
  87. Supervisor = host.Supervisor
  88. // Party is just a group joiner of routes which have the same prefix and share same middleware(s) also.
  89. // Party could also be named as 'Join' or 'Node' or 'Group' , Party chosen because it is fun.
  90. //
  91. // Look the `core/router#APIBuilder` for its implementation.
  92. //
  93. // A shortcut for the `core/router#Party`, useful when `PartyFunc` is being used.
  94. Party = router.Party
  95. // APIContainer is a wrapper of a common `Party` featured by Dependency Injection.
  96. // See `Party.ConfigureContainer` for more.
  97. //
  98. // A shortcut for the `core/router#APIContainer`.
  99. APIContainer = router.APIContainer
  100. // ResultHandler describes the function type which should serve the "v" struct value.
  101. // See `APIContainer.UseResultHandler`.
  102. ResultHandler = hero.ResultHandler
  103. // DirOptions contains the optional settings that
  104. // `FileServer` and `Party#HandleDir` can use to serve files and assets.
  105. // A shortcut for the `router.DirOptions`, useful when `FileServer` or `HandleDir` is being used.
  106. DirOptions = router.DirOptions
  107. // DirCacheOptions holds the options for the cached file system.
  108. // See `DirOptions`.
  109. DirCacheOptions = router.DirCacheOptions
  110. // DirListRichOptions the options for the `DirListRich` helper function.
  111. // A shortcut for the `router.DirListRichOptions`.
  112. // Useful when `DirListRich` function is passed to `DirOptions.DirList` field.
  113. DirListRichOptions = router.DirListRichOptions
  114. // Attachments options for files to be downloaded and saved locally by the client.
  115. // See `DirOptions`.
  116. Attachments = router.Attachments
  117. // Dir implements FileSystem using the native file system restricted to a
  118. // specific directory tree, can be passed to the `FileServer` function
  119. // and `HandleDir` method. It's an alias of `http.Dir`.
  120. Dir = http.Dir
  121. // ExecutionRules gives control to the execution of the route handlers outside of the handlers themselves.
  122. // Usage:
  123. // Party#SetExecutionRules(ExecutionRules {
  124. // Done: ExecutionOptions{Force: true},
  125. // })
  126. //
  127. // See `core/router/Party#SetExecutionRules` for more.
  128. // Example: https://github.com/kataras/iris/tree/master/_examples/mvc/middleware/without-ctx-next
  129. ExecutionRules = router.ExecutionRules
  130. // ExecutionOptions is a set of default behaviors that can be changed in order to customize the execution flow of the routes' handlers with ease.
  131. //
  132. // See `ExecutionRules` and `core/router/Party#SetExecutionRules` for more.
  133. ExecutionOptions = router.ExecutionOptions
  134. // CookieOption is the type of function that is accepted on
  135. // context's methods like `SetCookieKV`, `RemoveCookie` and `SetCookie`
  136. // as their (last) variadic input argument to amend the end cookie's form.
  137. //
  138. // Any custom or builtin `CookieOption` is valid,
  139. // see `CookiePath`, `CookieCleanPath`, `CookieExpires` and `CookieHTTPOnly` for more.
  140. //
  141. // An alias for the `context.CookieOption`.
  142. CookieOption = context.CookieOption
  143. // N is a struct which can be passed on the `Context.Negotiate` method.
  144. // It contains fields which should be filled based on the `Context.Negotiation()`
  145. // server side values. If no matched mime then its "Other" field will be sent,
  146. // which should be a string or []byte.
  147. // It completes the `context/context.ContentSelector` interface.
  148. //
  149. // An alias for the `context.N`.
  150. N = context.N
  151. )
  152. // Constants for input argument at `router.RouteRegisterRule`.
  153. // See `Party#SetRegisterRule`.
  154. const (
  155. // RouteOverride replaces an existing route with the new one, the default rule.
  156. RouteOverride = router.RouteOverride
  157. // RouteSkip keeps the original route and skips the new one.
  158. RouteSkip = router.RouteSkip
  159. // RouteError log when a route already exists, shown after the `Build` state,
  160. // server never starts.
  161. RouteError = router.RouteError
  162. // RouteOverlap will overlap the new route to the previous one.
  163. // If the route stopped and its response can be reset then the new route will be execute.
  164. RouteOverlap = router.RouteOverlap
  165. )
  166. // Contains the enum values of the `Context.GetReferrer()` method,
  167. // shortcuts of the context subpackage.
  168. const (
  169. ReferrerInvalid = context.ReferrerInvalid
  170. ReferrerIndirect = context.ReferrerIndirect
  171. ReferrerDirect = context.ReferrerDirect
  172. ReferrerEmail = context.ReferrerEmail
  173. ReferrerSearch = context.ReferrerSearch
  174. ReferrerSocial = context.ReferrerSocial
  175. ReferrerNotGoogleSearch = context.ReferrerNotGoogleSearch
  176. ReferrerGoogleOrganicSearch = context.ReferrerGoogleOrganicSearch
  177. ReferrerGoogleAdwords = context.ReferrerGoogleAdwords
  178. )
  179. // NoLayout to disable layout for a particular template file
  180. // A shortcut for the `view#NoLayout`.
  181. const NoLayout = view.NoLayout
  182. var (
  183. // HTML view engine.
  184. // Shortcut of the view.HTML.
  185. HTML = view.HTML
  186. // Blocks view engine.
  187. // Can be used as a faster alternative of the HTML engine.
  188. // Shortcut of the view.Blocks.
  189. Blocks = view.Blocks
  190. // Django view engine.
  191. // Shortcut of the view.Django.
  192. Django = view.Django
  193. // Handlebars view engine.
  194. // Shortcut of the view.Handlebars.
  195. Handlebars = view.Handlebars
  196. // Pug view engine.
  197. // Shortcut of the view.Pug.
  198. Pug = view.Pug
  199. // Amber view engine.
  200. // Shortcut of the view.Amber.
  201. Amber = view.Amber
  202. // Jet view engine.
  203. // Shortcut of the view.Jet.
  204. Jet = view.Jet
  205. // Ace view engine.
  206. // Shortcut of the view.Ace.
  207. Ace = view.Ace
  208. )
  209. // PrefixDir returns a new FileSystem that opens files
  210. // by adding the given "prefix" to the directory tree of "fs".
  211. func PrefixDir(prefix string, fs http.FileSystem) http.FileSystem {
  212. return &prefixedDir{prefix, fs}
  213. }
  214. type prefixedDir struct {
  215. prefix string
  216. fs http.FileSystem
  217. }
  218. func (p *prefixedDir) Open(name string) (http.File, error) {
  219. name = path.Join(p.prefix, name)
  220. return p.fs.Open(name)
  221. }
  222. var (
  223. // Compression is a middleware which enables
  224. // writing and reading using the best offered compression.
  225. Compression = func(ctx Context) {
  226. ctx.CompressWriter(true)
  227. ctx.CompressReader(true)
  228. ctx.Next()
  229. }
  230. // MatchImagesAssets is a simple regex expression
  231. // that can be passed to the DirOptions.Cache.CompressIgnore field
  232. // in order to skip compression on already-compressed file types
  233. // such as images and pdf.
  234. MatchImagesAssets = regexp.MustCompile("((.*).pdf|(.*).jpg|(.*).jpeg|(.*).gif|(.*).tif|(.*).tiff)$")
  235. // MatchCommonAssets is a simple regex expression which
  236. // can be used on `DirOptions.PushTargetsRegexp`.
  237. // It will match and Push
  238. // all available js, css, font and media files.
  239. // Ideal for Single Page Applications.
  240. MatchCommonAssets = regexp.MustCompile("((.*).js|(.*).css|(.*).ico|(.*).png|(.*).ttf|(.*).svg|(.*).webp|(.*).gif)$")
  241. )
  242. var (
  243. // RegisterOnInterrupt registers a global function to call when CTRL+C/CMD+C pressed or a unix kill command received.
  244. //
  245. // A shortcut for the `host#RegisterOnInterrupt`.
  246. RegisterOnInterrupt = host.RegisterOnInterrupt
  247. // LimitRequestBodySize is a middleware which sets a request body size limit
  248. // for all next handlers in the chain.
  249. //
  250. // A shortcut for the `context#LimitRequestBodySize`.
  251. LimitRequestBodySize = context.LimitRequestBodySize
  252. // NewConditionalHandler returns a single Handler which can be registered
  253. // as a middleware.
  254. // Filter is just a type of Handler which returns a boolean.
  255. // Handlers here should act like middleware, they should contain `ctx.Next` to proceed
  256. // to the next handler of the chain. Those "handlers" are registered to the per-request context.
  257. //
  258. //
  259. // It checks the "filter" and if passed then
  260. // it, correctly, executes the "handlers".
  261. //
  262. // If passed, this function makes sure that the Context's information
  263. // about its per-request handler chain based on the new "handlers" is always updated.
  264. //
  265. // If not passed, then simply the Next handler(if any) is executed and "handlers" are ignored.
  266. // Example can be found at: _examples/routing/conditional-chain.
  267. //
  268. // A shortcut for the `context#NewConditionalHandler`.
  269. NewConditionalHandler = context.NewConditionalHandler
  270. // FileServer returns a Handler which serves files from a specific system, phyisical, directory
  271. // or an embedded one.
  272. // The first parameter is the directory, relative to the executable program.
  273. // The second optional parameter is any optional settings that the caller can use.
  274. //
  275. // See `Party#HandleDir` too.
  276. // Examples can be found at: https://github.com/kataras/iris/tree/master/_examples/file-server
  277. // A shortcut for the `router.FileServer`.
  278. FileServer = router.FileServer
  279. // DirListRich can be passed to `DirOptions.DirList` field
  280. // to override the default file listing appearance.
  281. // Read more at: `core/router.DirListRich`.
  282. DirListRich = router.DirListRich
  283. // StripPrefix returns a handler that serves HTTP requests
  284. // by removing the given prefix from the request URL's Path
  285. // and invoking the handler h. StripPrefix handles a
  286. // request for a path that doesn't begin with prefix by
  287. // replying with an HTTP 404 not found error.
  288. //
  289. // Usage:
  290. // fileserver := iris.FileServer("./static_files", DirOptions {...})
  291. // h := iris.StripPrefix("/static", fileserver)
  292. // app.Get("/static/{file:path}", h)
  293. // app.Head("/static/{file:path}", h)
  294. StripPrefix = router.StripPrefix
  295. // FromStd converts native http.Handler, http.HandlerFunc & func(w, r, next) to context.Handler.
  296. //
  297. // Supported form types:
  298. // .FromStd(h http.Handler)
  299. // .FromStd(func(w http.ResponseWriter, r *http.Request))
  300. // .FromStd(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc))
  301. //
  302. // A shortcut for the `handlerconv#FromStd`.
  303. FromStd = handlerconv.FromStd
  304. // Cache is a middleware providing server-side cache functionalities
  305. // to the next handlers, can be used as: `app.Get("/", iris.Cache, aboutHandler)`.
  306. // It should be used after Static methods.
  307. // See `iris#Cache304` for an alternative, faster way.
  308. //
  309. // Examples can be found at: https://github.com/kataras/iris/tree/master/_examples/#caching
  310. Cache = cache.Handler
  311. // NoCache is a middleware which overrides the Cache-Control, Pragma and Expires headers
  312. // in order to disable the cache during the browser's back and forward feature.
  313. //
  314. // A good use of this middleware is on HTML routes; to refresh the page even on "back" and "forward" browser's arrow buttons.
  315. //
  316. // See `iris#StaticCache` for the opposite behavior.
  317. //
  318. // A shortcut of the `cache#NoCache`
  319. NoCache = cache.NoCache
  320. // StaticCache middleware for caching static files by sending the "Cache-Control" and "Expires" headers to the client.
  321. // It accepts a single input parameter, the "cacheDur", a time.Duration that it's used to calculate the expiration.
  322. //
  323. // If "cacheDur" <=0 then it returns the `NoCache` middleware instaed to disable the caching between browser's "back" and "forward" actions.
  324. //
  325. // Usage: `app.Use(iris.StaticCache(24 * time.Hour))` or `app.Use(iris.StaticCache(-1))`.
  326. // A middleware, which is a simple Handler can be called inside another handler as well, example:
  327. // cacheMiddleware := iris.StaticCache(...)
  328. // func(ctx iris.Context){
  329. // cacheMiddleware(ctx)
  330. // [...]
  331. // }
  332. //
  333. // A shortcut of the `cache#StaticCache`
  334. StaticCache = cache.StaticCache
  335. // Cache304 sends a `StatusNotModified` (304) whenever
  336. // the "If-Modified-Since" request header (time) is before the
  337. // time.Now() + expiresEvery (always compared to their UTC values).
  338. // Use this, which is a shortcut of the, `chache#Cache304` instead of the "github.com/kataras/iris/cache" or iris.Cache
  339. // for better performance.
  340. // Clients that are compatible with the http RCF (all browsers are and tools like postman)
  341. // will handle the caching.
  342. // The only disadvantage of using that instead of server-side caching
  343. // is that this method will send a 304 status code instead of 200,
  344. // So, if you use it side by side with other micro services
  345. // you have to check for that status code as well for a valid response.
  346. //
  347. // Developers are free to extend this method's behavior
  348. // by watching system directories changes manually and use of the `ctx.WriteWithExpiration`
  349. // with a "modtime" based on the file modified date,
  350. // similar to the `HandleDir`(which sends status OK(200) and browser disk caching instead of 304).
  351. //
  352. // A shortcut of the `cache#Cache304`.
  353. Cache304 = cache.Cache304
  354. // CookieAllowReclaim accepts the Context itself.
  355. // If set it will add the cookie to (on `CookieSet`, `CookieSetKV`, `CookieUpsert`)
  356. // or remove the cookie from (on `CookieRemove`) the Request object too.
  357. //
  358. // A shortcut for the `context#CookieAllowReclaim`.
  359. CookieAllowReclaim = context.CookieAllowReclaim
  360. // CookieAllowSubdomains set to the Cookie Options
  361. // in order to allow subdomains to have access to the cookies.
  362. // It sets the cookie's Domain field (if was empty) and
  363. // it also sets the cookie's SameSite to lax mode too.
  364. //
  365. // A shortcut for the `context#CookieAllowSubdomains`.
  366. CookieAllowSubdomains = context.CookieAllowSubdomains
  367. // CookieSameSite sets a same-site rule for cookies to set.
  368. // SameSite allows a server to define a cookie attribute making it impossible for
  369. // the browser to send this cookie along with cross-site requests. The main
  370. // goal is to mitigate the risk of cross-origin information leakage, and provide
  371. // some protection against cross-site request forgery attacks.
  372. //
  373. // See https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00 for details.
  374. //
  375. // A shortcut for the `context#CookieSameSite`.
  376. CookieSameSite = context.CookieHTTPOnly
  377. // CookieSecure sets the cookie's Secure option if the current request's
  378. // connection is using TLS. See `CookieHTTPOnly` too.
  379. //
  380. // A shortcut for the `context#CookieSecure`.
  381. CookieSecure = context.CookieSecure
  382. // CookieHTTPOnly is a `CookieOption`.
  383. // Use it to set the cookie's HttpOnly field to false or true.
  384. // HttpOnly field defaults to true for `RemoveCookie` and `SetCookieKV`.
  385. //
  386. // A shortcut for the `context#CookieHTTPOnly`.
  387. CookieHTTPOnly = context.CookieHTTPOnly
  388. // CookiePath is a `CookieOption`.
  389. // Use it to change the cookie's Path field.
  390. //
  391. // A shortcut for the `context#CookiePath`.
  392. CookiePath = context.CookiePath
  393. // CookieCleanPath is a `CookieOption`.
  394. // Use it to clear the cookie's Path field, exactly the same as `CookiePath("")`.
  395. //
  396. // A shortcut for the `context#CookieCleanPath`.
  397. CookieCleanPath = context.CookieCleanPath
  398. // CookieExpires is a `CookieOption`.
  399. // Use it to change the cookie's Expires and MaxAge fields by passing the lifetime of the cookie.
  400. //
  401. // A shortcut for the `context#CookieExpires`.
  402. CookieExpires = context.CookieExpires
  403. // CookieEncoding accepts a value which implements `Encode` and `Decode` methods.
  404. // It calls its `Encode` on `Context.SetCookie, UpsertCookie, and SetCookieKV` methods.
  405. // And on `Context.GetCookie` method it calls its `Decode`.
  406. //
  407. // A shortcut for the `context#CookieEncoding`.
  408. CookieEncoding = context.CookieEncoding
  409. // IsErrPath can be used at `context#ReadForm` and `context#ReadQuery`.
  410. // It reports whether the incoming error is type of `formbinder.ErrPath`,
  411. // which can be ignored when server allows unknown post values to be sent by the client.
  412. //
  413. // A shortcut for the `context#IsErrPath`.
  414. IsErrPath = context.IsErrPath
  415. // ErrEmptyForm is the type error which API users can make use of
  416. // to check if a form was empty on `Context.ReadForm`.
  417. //
  418. // A shortcut for the `context#ErrEmptyForm`.
  419. ErrEmptyForm = context.ErrEmptyForm
  420. // NewProblem returns a new Problem.
  421. // Head over to the `Problem` type godoc for more.
  422. //
  423. // A shortcut for the `context#NewProblem`.
  424. NewProblem = context.NewProblem
  425. // XMLMap wraps a map[string]interface{} to compatible xml marshaler,
  426. // in order to be able to render maps as XML on the `Context.XML` method.
  427. //
  428. // Example: `Context.XML(XMLMap("Root", map[string]interface{}{...})`.
  429. //
  430. // A shortcut for the `context#XMLMap`.
  431. XMLMap = context.XMLMap
  432. // ErrStopExecution if returned from a hero middleware or a request-scope dependency
  433. // stops the handler's execution, see _examples/dependency-injection/basic/middleware.
  434. ErrStopExecution = hero.ErrStopExecution
  435. // ErrHijackNotSupported is returned by the Hijack method to
  436. // indicate that Hijack feature is not available.
  437. //
  438. // A shortcut for the `context#ErrHijackNotSupported`.
  439. ErrHijackNotSupported = context.ErrHijackNotSupported
  440. // ErrPushNotSupported is returned by the Push method to
  441. // indicate that HTTP/2 Push support is not available.
  442. //
  443. // A shortcut for the `context#ErrPushNotSupported`.
  444. ErrPushNotSupported = context.ErrPushNotSupported
  445. )
  446. // HTTP Methods copied from `net/http`.
  447. const (
  448. MethodGet = http.MethodGet
  449. MethodPost = http.MethodPost
  450. MethodPut = http.MethodPut
  451. MethodDelete = http.MethodDelete
  452. MethodConnect = http.MethodConnect
  453. MethodHead = http.MethodHead
  454. MethodPatch = http.MethodPatch
  455. MethodOptions = http.MethodOptions
  456. MethodTrace = http.MethodTrace
  457. // MethodNone is an iris-specific "virtual" method
  458. // to store the "offline" routes.
  459. MethodNone = router.MethodNone
  460. )
  461. // HTTP status codes as registered with IANA.
  462. // See: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml.
  463. // Raw Copy from the future(tip) net/http std package in order to recude the import path of "net/http" for the users.
  464. const (
  465. StatusContinue = http.StatusContinue
  466. StatusSwitchingProtocols = http.StatusSwitchingProtocols
  467. StatusProcessing = http.StatusProcessing
  468. StatusEarlyHints = http.StatusEarlyHints
  469. StatusOK = http.StatusOK
  470. StatusCreated = http.StatusCreated
  471. StatusAccepted = http.StatusAccepted
  472. StatusNonAuthoritativeInfo = http.StatusNonAuthoritativeInfo
  473. StatusNoContent = http.StatusNoContent
  474. StatusResetContent = http.StatusResetContent
  475. StatusPartialContent = http.StatusPartialContent
  476. StatusMultiStatus = http.StatusMultiStatus
  477. StatusAlreadyReported = http.StatusAlreadyReported
  478. StatusIMUsed = http.StatusIMUsed
  479. StatusMultipleChoices = http.StatusMultipleChoices
  480. StatusMovedPermanently = http.StatusMovedPermanently
  481. StatusFound = http.StatusFound
  482. StatusSeeOther = http.StatusSeeOther
  483. StatusNotModified = http.StatusNotModified
  484. StatusUseProxy = http.StatusUseProxy
  485. StatusTemporaryRedirect = http.StatusTemporaryRedirect
  486. StatusPermanentRedirect = http.StatusPermanentRedirect
  487. StatusBadRequest = http.StatusBadRequest
  488. StatusUnauthorized = http.StatusUnauthorized
  489. StatusPaymentRequired = http.StatusPaymentRequired
  490. StatusForbidden = http.StatusForbidden
  491. StatusNotFound = http.StatusNotFound
  492. StatusMethodNotAllowed = http.StatusMethodNotAllowed
  493. StatusNotAcceptable = http.StatusNotAcceptable
  494. StatusProxyAuthRequired = http.StatusProxyAuthRequired
  495. StatusRequestTimeout = http.StatusRequestTimeout
  496. StatusConflict = http.StatusConflict
  497. StatusGone = http.StatusGone
  498. StatusLengthRequired = http.StatusLengthRequired
  499. StatusPreconditionFailed = http.StatusPreconditionFailed
  500. StatusRequestEntityTooLarge = http.StatusRequestEntityTooLarge
  501. StatusPayloadTooRage = StatusRequestEntityTooLarge
  502. StatusRequestURITooLong = http.StatusRequestURITooLong
  503. StatusUnsupportedMediaType = http.StatusUnsupportedMediaType
  504. StatusRequestedRangeNotSatisfiable = http.StatusRequestedRangeNotSatisfiable
  505. StatusExpectationFailed = http.StatusExpectationFailed
  506. StatusTeapot = http.StatusTeapot
  507. StatusMisdirectedRequest = http.StatusMisdirectedRequest
  508. StatusUnprocessableEntity = http.StatusUnprocessableEntity
  509. StatusLocked = http.StatusLocked
  510. StatusFailedDependency = http.StatusFailedDependency
  511. StatusTooEarly = http.StatusTooEarly
  512. StatusUpgradeRequired = http.StatusUpgradeRequired
  513. StatusPreconditionRequired = http.StatusPreconditionRequired
  514. StatusTooManyRequests = http.StatusTooManyRequests
  515. StatusRequestHeaderFieldsTooLarge = http.StatusRequestHeaderFieldsTooLarge
  516. StatusUnavailableForLegalReasons = http.StatusUnavailableForLegalReasons
  517. // Unofficial Client Errors.
  518. StatusPageExpired = context.StatusPageExpired
  519. StatusBlockedByWindowsParentalControls = context.StatusBlockedByWindowsParentalControls
  520. StatusInvalidToken = context.StatusInvalidToken
  521. StatusTokenRequired = context.StatusTokenRequired
  522. //
  523. StatusInternalServerError = http.StatusInternalServerError
  524. StatusNotImplemented = http.StatusNotImplemented
  525. StatusBadGateway = http.StatusBadGateway
  526. StatusServiceUnavailable = http.StatusServiceUnavailable
  527. StatusGatewayTimeout = http.StatusGatewayTimeout
  528. StatusHTTPVersionNotSupported = http.StatusHTTPVersionNotSupported
  529. StatusVariantAlsoNegotiates = http.StatusVariantAlsoNegotiates
  530. StatusInsufficientStorage = http.StatusInsufficientStorage
  531. StatusLoopDetected = http.StatusLoopDetected
  532. StatusNotExtended = http.StatusNotExtended
  533. StatusNetworkAuthenticationRequired = http.StatusNetworkAuthenticationRequired
  534. // Unofficial Server Errors.
  535. StatusBandwidthLimitExceeded = context.StatusBandwidthLimitExceeded
  536. StatusInvalidSSLCertificate = context.StatusInvalidSSLCertificate
  537. StatusSiteOverloaded = context.StatusSiteOverloaded
  538. StatusSiteFrozen = context.StatusSiteFrozen
  539. StatusNetworkReadTimeout = context.StatusNetworkReadTimeout
  540. )
  541. // StatusText returns a text for the HTTP status code. It returns the empty
  542. // string if the code is unknown.
  543. //
  544. // Shortcut for core/router#StatusText.
  545. var StatusText = context.StatusText