route.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package context
  2. import (
  3. "io"
  4. "time"
  5. "github.com/kataras/iris/macro"
  6. )
  7. // RouteReadOnly allows decoupled access to the current route
  8. // inside the context.
  9. type RouteReadOnly interface {
  10. // Name returns the route's name.
  11. Name() string
  12. // StatusErrorCode returns 0 for common resource routes
  13. // or the error code that an http error handler registered on.
  14. StatusErrorCode() int
  15. // Method returns the route's method.
  16. Method() string
  17. // Subdomains returns the route's subdomain.
  18. Subdomain() string
  19. // Path returns the route's original registered path.
  20. Path() string
  21. // String returns the form of METHOD, SUBDOMAIN, TMPL PATH.
  22. String() string
  23. // IsOnline returns true if the route is marked as "online" (state).
  24. IsOnline() bool
  25. // IsStatic reports whether this route is a static route.
  26. // Does not contain dynamic path parameters,
  27. // is online and registered on GET HTTP Method.
  28. IsStatic() bool
  29. // StaticPath returns the static part of the original, registered route path.
  30. // if /user/{id} it will return /user
  31. // if /user/{id}/friend/{friendid:uint64} it will return /user too
  32. // if /assets/{filepath:path} it will return /assets.
  33. StaticPath() string
  34. // ResolvePath returns the formatted path's %v replaced with the args.
  35. ResolvePath(args ...string) string
  36. // Trace should writes debug route info to the "w".
  37. // Should be called after Build.
  38. Trace(w io.Writer)
  39. // Tmpl returns the path template,
  40. // it contains the parsed template
  41. // for the route's path.
  42. // May contain zero named parameters.
  43. //
  44. // Available after the build state, i.e a request handler or Iris Configurator.
  45. Tmpl() macro.Template
  46. // MainHandlerName returns the first registered handler for the route.
  47. MainHandlerName() string
  48. // MainHandlerIndex returns the first registered handler's index for the route.
  49. MainHandlerIndex() int
  50. // Sitemap properties: https://www.sitemaps.org/protocol.html
  51. // GetLastMod returns the date of last modification of the file served by this route.
  52. GetLastMod() time.Time
  53. // GetChangeFreq returns the the page frequently is likely to change.
  54. GetChangeFreq() string
  55. // GetPriority returns the priority of this route's URL relative to other URLs on your site.
  56. GetPriority() float32
  57. }