context.go 673 B

123456789101112131415161718192021222324252627282930313233
  1. package context
  2. import "net/http"
  3. //Context struct
  4. type Context struct {
  5. AppID string
  6. AppSecret string
  7. Token string
  8. EncodingAESKey string
  9. Writer http.ResponseWriter
  10. Request *http.Request
  11. }
  12. func (ctx *Context) getAccessToken() {
  13. }
  14. // Query returns the keyed url query value if it exists
  15. func (ctx *Context) Query(key string) string {
  16. value, _ := ctx.GetQuery(key)
  17. return value
  18. }
  19. // GetQuery is like Query(), it returns the keyed url query value
  20. func (ctx *Context) GetQuery(key string) (string, bool) {
  21. req := ctx.Request
  22. if values, ok := req.URL.Query()[key]; ok && len(values) > 0 {
  23. return values[0], true
  24. }
  25. return "", false
  26. }