aah Request and Response

This document provides an insights into aah Request and Response capabilities. So that it could be utilized effectively.

Table of Contents


aah Request extends form of standard request struct. It provides necessary values (derived and processed per RFCs).


Field NameDescription
SchemeRequest protocol value https or http, it’s a inferred value. Know more
HostValue of correct Host source from HTTP request
ProtoValue of current HTTP request protocol. (e.g. HTTP/1.1, HTTP/2.0)
MethodValue of HTTP verb name, such as GET, POST, etc
PathRequest URL Path e.g. /app/login.html
HeaderHTTP request headers
URLParamsURL path parameters values that was defined routes.conf
IsGzipAcceptedInferred value as bool, whether HTTP client supports Gzip compression or not.


Method NameDescription
AcceptContentTypeNegotiated value of HTTP Header Accept. The resolve order is URL extension, Accept header per RFC7231 and Vendor Types per RFC4288
AcceptEncodingNegotiated value of HTTP Header the Accept-Encoding per RFC7231
ContentTypeParsed value of HTTP header Content-Type per RFC1521
BodyReturns the HTTP request body io.ReadCloser
SaveFileSaves an uploaded request multipart file for the given key into given destination file
LocaleNegotiated value of HTTP Header Accept-Language per RFC7231
ClientIPReturns remote Client IP address aka Remote IP. It parses in the order of given set of headers otherwise it uses default header set X-Forwarded-For, X-Real-IP, X-Appengine-Remote-Addr and finally http.Request.RemoteAddr
CookieReturns a named cookie from HTTP request otherwise error
CookiesReturns all the cookies from HTTP request
IsJSONPReturns true if request URL query string has callback=<function_name>
IsAJAXReturns true if request header X-Requested-With is XMLHttpRequest otherwise false
URLReturns request URL instance
RefererReturns value of HTTP ‘Referrer’ (or ‘Referer’) header.
UserAgentReturns value of HTTP ‘User-Agent’ header.
UnwrapReturns the underlying *http.Request instance of Go HTTP server, direct interaction with raw object is not encouraged.

It is highly recommended to use Auto Parse and Bind feature on controller action arguments. Non-controller (like middleware, etc.) location use following method appropriately.

Method NameDescription
PathValueReturns value for given Path param key otherwise empty string. For eg.: /users/:userId => PathValue("userId")
QueryValueReturns value for given URL query param key otherwise empty string
QueryArrayValueReturns array value for given URL query param key otherwise empty string slice
FormValueReturns value for given form key otherwise empty string
FormArrayValueReturns array value for given form key otherwise empty string slice
FormFileReturns the first file for the provided form key otherwise returns error. It is caller responsibility to close the file


aah resposne writer implements interfaces http.ResponseWriter, http.CloseNotifier, http.Flusher, http.Hijacker, http.Pusher and io.Closer.

And captuers following details -

  • Status() - returns response status code
  • BytesWritten() - returns the total number of bytes written into response. Does not include response header bytes size.
  • Unwrap() - returns the underlying ResponseWriter

It is highly recommended to use Reply Builder to compose response.