route.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package context
  2. import (
  3. "io"
  4. "time"
  5. "github.com/kataras/iris/v12/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, stoppedIndex int)
  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. // Property returns a specific property based on its "key"
  51. // of this route's Party owner.
  52. Property(key string) (interface{}, bool)
  53. // Sitemap properties: https://www.sitemaps.org/protocol.html
  54. // GetLastMod returns the date of last modification of the file served by this route.
  55. GetLastMod() time.Time
  56. // GetChangeFreq returns the the page frequently is likely to change.
  57. GetChangeFreq() string
  58. // GetPriority returns the priority of this route's URL relative to other URLs on your site.
  59. GetPriority() float32
  60. }