Dev Support or Need Help?

  •   Chat on Gitter
  •   Github Issues
  •   Ask on StackOverflow - tag aahframework

Report improvements/bugs at Github Issues, help me to improve aah framework.

Reply Builder

Framework provides Reply builder (aka Response Builder) to compose your response effectively. You can do Chained call.

Table of Contents

Response Status Codes

As per RFC7231, provides method for frequently used ones.

  • Ok()
  • Created()
  • Accepted()
  • NoContent()
  • MovedPermanently()
  • Found()
  • TemporaryRedirect()
  • BadRequest()
  • Unauthorized()
  • Forbidden()
  • NotFound()
  • MethodNotAllowed()
  • Conflict()
  • InternalServerError()
  • ServiceUnavailable()

ohh, the response status I need is not in the above list, no problem; just use Reply().Status(http.StatusPartialContent) or Reply().Status(206)

Response Content

Rich reply methods for the response.

  • HTML(data)
  • HTMLl(layout, data)
  • HTMLf(filename, data)
  • HTMLlf(layout, filename, data)
  • JSON(data)
  • JSONP(data, callback)
  • XML(data)
  • Text(str)
  • Text(str, args)
  • Readfrom(reader)
  • File(file)
  • FileDownload(file, targetName) - Content-Disposition is attachment
  • FileInline(file, targetName) - Content-Disposition is inline
  • Binary(bytes)


  • Redirect(url)
  • RedirectSts(url, statusCode)

Replying HTTP Headers

  • Header(hdr, value)
  • HeaderAppend(hdr, value)


  • Cookie(cookie)

Disable Gzip

By default framework doesn’t apply Gzip compression for Status Codes 204, 304 and if client doesn’t support gzip. On top of it framework provides DisableGzip method as an option to disable gzip compression for a particular response.



Done method indicates that reply has already been sent via aah.Context.Res and that no further action is needed.

Note: Framework doesn’t intervene with response if Done() method was called.

Just Few Samples

Refer to Response Status Codes and Response Content to know more.

// Replying JSON with Status Code 200 OK

// Default Status Code is 200 OK, so you can do

// Replying JSON with Status Code 400 BAD REQUEST

// Replying file as an attachment from absolute path
// Default Status Code is 200 OK
Reply().FileDownload("/User/jeeva/songs/nice.mp3", "name-nice.mp3")

// I just want serve file from controller
// If file param is relative path, framework resolves it from `static` directory
// like <app-base-dir>/static/reports/daily.pdf

// I would like to send binary data

// I would like to use Reader

// Replying redirect login page using `route name`

// Replying HTML response with cookie and view arguments

// Replying HTML response with custom layout and data
Reply().HTMLl("master-custom.html", data)