###################################################
# benchmark - aah framework application
#
# Complete configuration reference:
#   https://docs.aahframework.org/app-config.html
###################################################

# Application name (non-whitespace)
# Default value is `basename` of import path.
name = "benchmark"

# Friendly description of application
desc = "aah framework web application"

# Configure file path of application PID file to be written.
# Ensure application has appropriate permission and directory exists.
# Default value is `<app-base-dir>/<app-binary-name>.pid`
#pid_file = "/path/to/pidfile.pid"

# -----------------------------------------------------------------
# Server configuration - HTTP
# Doc: https://docs.aahframework.org/app-config.html#section-server
# -----------------------------------------------------------------
server {
  # For unix socket: unix:/tmp/aahframework.sock
  # Default value is `empty` string.
  #address = ""

  # For port `80` and `443`, put empty string or a value
  # Default value is 8080.
  #port = ""

  # Header value written as `Server` HTTP header.
  # If you do not want to include `Server` header, comment it out.
  header = "aah-go-server"

  # Valid time units are "s = seconds", "m = minutes"
  timeout {
    # mapped to `http.Server.ReadTimeout`.
    # Default value is `90s`.
    #read = "90s"

    # mapped to `http.Server.WriteTimeout`
    # Default value is `90s`.
    #write = "90s"

    # aah sever graceful shutdown timeout
    # Note: applicable only to go1.8 and above
    # Default value is `60s`.
    #grace_shutdown = "60s"
  }

  # Mapped to `http.Server.MaxHeaderBytes`.
  # Default value is `1mb`.
  #max_header_bytes = "1mb"

  # HTTP server keep alive option.
  # Default value is `true`.
  #keep_alive = true

  ssl {
    # Default value is `false`.
    #enable = false

    # Default value is `empty` string.
    #cert = ""

    # Default value is `empty` string.
    #key = ""

    # Disabling HTTP/2 set it true.
    # Default value is `false`.
    #disable_http2 = true

    lets_encrypt {
      # To get SSL certificate from Let's Encrypt CA, enable it.
      # Don't forget to enable `server.ssl.enable=true`.
      # Default value is `false`.
      #enable = false

      # Host policy controls which domains the autocert will attempt
      # to retrieve new certificates for. It does not affect cached certs.
      # It is required, no default value.
      #host_policy = ["example.org", "docs.example.org"]

      # Renew before optionally specifies how early certificates should
      # be renewed before they expire.
      # Default value is `10` days.
      #renew_before = 10

      # Email optionally specifies a contact email address. This is used by CAs,
      # such as Let's Encrypt, to notify about problems with issued certificates.
      # If the Client's account key is already registered, Email is not used.
      #email = "jeeva@myjeeva.com"

      # Force RSA makes the autocert generate certificates with 2048-bit RSA keys.
      # If false, a default is used. Currently the default is
      # EC-based keys using the P-256 curve.
      #force_rsa = false

      # Cache optionally stores and retrieves previously-obtained certificates
      # autocert manager. By default certs will only be cached for the lifetime
      # of the autocert manager.
      #
      # autocert manager passes the Cache certificates data encoded in PEM,
      # with private/public parts combined in a single Cache.Put call,
      # private key first.
      # Default value is `empty` string
      #cache_dir = "/Users/jeeva/autocert"
    }
  }

  # To manage aah server effectively it is necessary to know details about the
  # request, response, processing time, client IP address, etc. aah framework
  # provides the flexible and configurable access log capabilities.
  access_log {
    # Enabling server access log
    # Default value is `false`.
    #enable = true

    # Absolute path to access log file or relative path.
    # Default location is application logs directory
    #file = "{{ .AppName }}-access.log"

    # Default server access log pattern
    #pattern = "%clientip %custom:- %reqtime %reqmethod %requrl %reqproto %resstatus %ressize %restime %reqhdr:referer"

    # Access Log channel buffer size
    # Default value is `500`.
    #channel_buffer_size = 500

    # Include static files access log too.
    # Default value is `true`.
    #static_file = false
  }
}

# ------------------------------------------------------------------
# Request configuration
# Doc: https://docs.aahframework.org/app-config.html#section-request
# ------------------------------------------------------------------
request {

  # aah framework encourages to have unique `Request Id` for each incoming
  # request, it helps in traceability. If request has already `X-Request-Id`
  # HTTP header then it does not generate one.
  id {
    # Default value is `true`.
    enable = false

    # Default value is `X-Request-Id`, change it if you have different one.
    #header = "X-Request-Id"
  }

  # Default value is `32mb`, choose your value based on your use case
  #multipart_size = "32mb"
}

# ---------------------------------------------------------------
# i18n configuration
# Doc: https://docs.aahframework.org/app-config.html#section-i18n
# ---------------------------------------------------------------
i18n {
  # It is used as fallback if framework is unable to determine the
  # locale from HTTP Request.
  # Default value is `en`.
  #default = "en"
}

# -----------------------------------------------------------------
# Format configuration
# Doc: https://docs.aahframework.org/app-config.html#section-format
# -----------------------------------------------------------------
format {
  # Time format for auto parse and bind. aah tries to parse the
  # time value in the order they defined till it gets success
  # otherwise returns the error.
  time = [
    "2006-01-02T15:04:05Z07:00",
    "2006-01-02T15:04:05Z",
    "2006-01-02 15:04:05",
    "2006-01-02"
  ]
}

# ------------------------------------------------------------------
# Runtime configuration
# Doc: https://docs.aahframework.org/app-config.html#section-runtime
# ------------------------------------------------------------------
runtime {
  debug {
    # Choose an appropriate buffer size for collecting all goroutines stack trace
    # dump based on your case.
    # Default value is `2mb`.
    #stack_buffer_size = "2mb"

    # Whether to collect all the Go routines details or not.
    # Default value is `false`.
    #all_goroutines = true
  }
}

# -----------------------------------------------------------------
# Render configuration
# Doc: https://docs.aahframework.org/app-config.html#section-render
# -----------------------------------------------------------------
render {
  # aah framework chooses the `Content-Type` value automatically based on
  # configuration if `aah.Reply()` builder value is not set. It selects in
  # the order of:
  #  - Based on URL file extension, supported `.html`, `.htm`, `.json`, `.js`, `.xml` and `.txt`
  #  - Request Accept Header - Most Qualified one as per RFC7321
  #  - Based `render.default` value supported types are `html`, `json`, `xml` and `text`
  #  - Finally aah framework uses `http.DetectContentType` API
  # Default value is `empty` string.
  default = "html"

  # Pretty print option is helpful in `dev` environment profile.
  # It is only applicable to JSON and XML.
  # Default value is `false`.
  #pretty = true

  # Gzip compression configuration for HTTP response.
  gzip {
    # By default Gzip compression is enabled in aah framework, however
    # framework ensures HTTP client accepts Gzip response otherwise
    # it won't use Gzip compression.
    #
    # Tips: If you have nginx or apache web server enabled with gzip in-front
    # of aah server the set this value to `false`.
    #
    # Default value is `true`.
    enable = false

    # Used to control Gzip compression levels. Valid levels are
    # 1 = BestSpeed to 9 = BestCompression.
    # Default value is `4`.
    #level = 4
  }
}

# ------------------------------------------------------------------
# Cache configuration
# Doc: https://docs.aahframework.org/static-files.html#cache-control
# ------------------------------------------------------------------
cache {
  static {
    # Default `Cache-Control` for all static files,
    # if specific mime type is not defined.
    default_cache_control = "public, max-age=31536000"

    # Define by mime types, if mime is not present then default is applied.
    # Config is very flexible to define by mime type.
    #
    # Create a unique name and provide `mime` with comma separated value
    # and `cache_control`.
    # mime_types {
    #   css_js {
    #     mime = "text/css, application/javascript"
    #     cache_control = "public, max-age=604800, proxy-revalidate"
    #   }
    #
    #   images {
    #     mime = "image/jpeg, image/png, image/gif, image/svg+xml, image/x-icon"
    #     cache_control = "public, max-age=2628000, proxy-revalidate"
    #   }
    # }
  }
}

# ---------------------------------------------------------------
# View configuration
# Doc: https://docs.aahframework.org/app-config.html#section-view
# ---------------------------------------------------------------
view {
  # Choosing view engine for application. In the upcoming release framework
  # will provide support to amber, pongo2, and jade. However you can implement
  # on your own with simple `view.Enginer` interface.
  # Default value is `go`. Currently only `go` is supported.
  #engine = "go"

  # Choose your own view file extension.
  # Default value is `.html`.
  #ext = ".html"

  # Choose whether you need a case sensitive view file resolve or not.
  # For e.g.: "/views/pages/app/login.tmpl" == "/views/pages/App/Login.tmpl"
  # Default value is `false`.
  #case_sensitive = false

  # To use custom Go template delimiters for view files.
  # Default value is `{{.}}`.
  #delimiters = "{{.}}"

  # Framework chooses the default app layout as `master.html` if you do not
  # provide one. However you may have pages or template without layout too.
  # So option to disable the default layout for HTML.
  # Default value is `true`. Available since v0.6
  #default_layout = false
}

# DataSource config
datasource {
  benchmark {
    driver = "mysql"
    url = "benchmarkdbuser:benchmarkdbpass@tcp(%s:3306)/hello_world"
  }
}

# --------------------------------------------------------------
# Application Security
# Doc: https://docs.aahframework.org/security-config.html
# --------------------------------------------------------------
include "./security.conf"

# --------------------------------------------------------------
# Environment Profiles e.g.: dev, qa, prod
# Doc: https://docs.aahframework.org/app-config.html#section-env
# --------------------------------------------------------------
env {
  # Indicates active profile name for application configuration.
  # Default value is `dev`.
  #active = "dev"

  # ----------------------------------
  # Environment profile configurations
  # ----------------------------------
  include "./env/*.conf"
}
