base.go 636 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package param
  2. import (
  3. "context"
  4. "net/url"
  5. )
  6. func GetQuery(c context.Context) url.Values {
  7. query := c.Value("query")
  8. if _, ok := query.(url.Values); ok {
  9. return query.(url.Values)
  10. }
  11. return url.Values{}
  12. }
  13. func GetFromPath(c context.Context) string {
  14. path := c.Value("from_path")
  15. if _, ok := path.(string); ok {
  16. return path.(string)
  17. }
  18. return ""
  19. }
  20. func GetBody(c context.Context) []byte {
  21. body := c.Value("body")
  22. if _, ok := body.([]byte); ok {
  23. return body.([]byte)
  24. }
  25. return nil
  26. }
  27. func GetUri(c context.Context) string {
  28. uri := c.Value("uri")
  29. if _, ok := uri.(string); ok {
  30. return uri.(string)
  31. }
  32. return ""
  33. }