Skip to content

Commit

Permalink
Merge pull request #11 for v0.8 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm authored Sep 1, 2017
2 parents 7e00273 + e596c4d commit c4aa79e
Show file tree
Hide file tree
Showing 18 changed files with 464 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ branches:

go:
- 1.8
- 1.8.x
- 1.9
- tip

go_import_path: aahframework.org/tools.v0/aah
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Home of all aah framework CLI tools.
## aah CLI Tool
[![Build Status](https://travis-ci.org/go-aah/tools.svg?branch=master)](https://travis-ci.org/go-aah/tools) [![Go Report Card](https://goreportcard.com/badge/aahframework.org/tools.v0)](https://goreportcard.com/report/aahframework.org/tools.v0/aah)
[![Powered by Go](https://img.shields.io/badge/powered_by-go-blue.svg)](https://golang.org)
[![Version](https://img.shields.io/badge/version-0.7-blue.svg)](https://github.com/go-aah/tools/releases/latest)
[![Version](https://img.shields.io/badge/version-0.8-blue.svg)](https://github.com/go-aah/tools/releases/latest)
[![License](https://img.shields.io/github/license/go-aah/tools.svg)](LICENSE) [![Twitter](https://img.shields.io/badge/twitter-@aahframework-55acee.svg)](https://twitter.com/aahframework)

***Release [v0.7](https://github.com/go-aah/tools/releases/latest) tagged on Aug 01, 2017***
***Release [v0.8](https://github.com/go-aah/tools/releases/latest) tagged on Sep 01, 2017***

aah framework - A scalable, performant, rapid development Web framework for Go.

Expand Down
47 changes: 32 additions & 15 deletions aah/aah.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
Expand All @@ -26,17 +27,11 @@ import (
"aahframework.org/router.v0"
"aahframework.org/security.v0"
"aahframework.org/test.v0"
"aahframework.org/valpar.v0"
"aahframework.org/view.v0"
)

// Version no. of aah framework CLI tool
const Version = "0.7"

const (
header = `–––––––––––––––––––––––––––––––––––––––––––––––––––––
aah framework v%s - https://aahframework.org
–––––––––––––––––––––––––––––––––––––––––––––––––––––
`
aahImportPath = "aahframework.org/aah.v0"
aahCLIImportPath = "aahframework.org/tools.v0/aah"
permRWXRXRX = 0755
Expand Down Expand Up @@ -111,23 +106,45 @@ func main() {

sort.Sort(cli.FlagsByName(app.Flags))
_ = app.Run(os.Args)
return
}

//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// Unexported methods
//___________________________________

func printHeader(c *cli.Context) error {
if isWindowsOS() {
fmt.Fprintf(c.App.Writer, header, aah.Version)
} else {
fmt.Fprintf(c.App.Writer, fmt.Sprintf("\033[1;32m%v\033[0m", header), aah.Version)
hdr := fmt.Sprintf("aah framework v%s - https://aahframework.org", aah.Version)
improveRpt := "# Report improvements/bugs at https://github.com/go-aah/aah/issues #"
cnt := len(improveRpt)
sp := (cnt - len(hdr)) / 2

if !isWindowsOS() {
fmt.Fprintf(c.App.Writer, "\033[1;32m")
}

printChr(c.App.Writer, "–", cnt)
fmt.Fprintf(c.App.Writer, "\n")
printChr(c.App.Writer, " ", sp)
fmt.Fprintf(c.App.Writer, hdr)
printChr(c.App.Writer, " ", sp)
fmt.Fprintf(c.App.Writer, "\n")
printChr(c.App.Writer, "–", cnt)
fmt.Fprintf(c.App.Writer, "\n")

if !isWindowsOS() {
fmt.Fprintf(c.App.Writer, "\033[0m")
}
fmt.Fprintf(c.App.Writer, "# Report improvements/bugs at https://github.com/go-aah/aah/issues\n\n")

fmt.Fprintf(c.App.Writer, improveRpt+"\n\n")
return nil
}

func printChr(w io.Writer, chr string, cnt int) {
for idx := 0; idx < cnt; idx++ {
fmt.Fprintf(w, chr)
}
}

func init() {
cli.HelpFlag = cli.BoolFlag{
Name: "h, help",
Expand All @@ -151,8 +168,8 @@ func init() {
"security v" + security.Version}, ", "))
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", "", strings.Join(
[]string{"i18n v" + i18n.Version, "view v" + view.Version,
"log v" + log.Version, "test v" + test.Version, "aruntime v" + aruntime.Version,
}, ", "))
"log v" + log.Version, "test v" + test.Version,
"aruntime v" + aruntime.Version, "valpar v" + valpar.Version}, ", "))
fmt.Println()
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", fmt.Sprintf("go[%s/%s]",
runtime.GOOS, runtime.GOARCH), runtime.Version()[2:])
Expand Down
4 changes: 2 additions & 2 deletions aah/app-template/aah.project.atmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
########################################
##############################################################
# {{ .AppName }} - aah framework project
#
# Note: Add it to version control
########################################
##############################################################

# Build section is used during aah application compile and build command.
build {
Expand Down
6 changes: 3 additions & 3 deletions aah/app-template/app/controllers/app.go.atmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"{{.AppImportPath}}/app/models"
)

// App struct application controller
type App struct {
// AppController struct application controller
type AppController struct {
*aah.Context
}

// Index method is application {{ if eq .AppType "web" -}}home page.{{ else }}root API endpoint.{{- end }}
func (a *App) Index() {
func (a *AppController) Index() {
{{- if eq .AppType "web" }}
data := aah.Data{
"Greet": models.Greet{
Expand Down
78 changes: 71 additions & 7 deletions aah/app-template/config/aah.conf.atmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ name = "{{ .AppName }}"
# Friendly description of application
desc = "aah framework {{ .AppType }} 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
Expand All @@ -25,6 +30,10 @@ server {
# 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`, is the maximum duration for reading
Expand Down Expand Up @@ -138,7 +147,6 @@ server {
# 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.
Expand All @@ -150,10 +158,62 @@ request {
#header = "X-Request-Id"
}

# Max request body size for all incoming HTTP requests except `MultipartForm`.
# Also you can override this size for individual route on specific cases
# in `routes.conf` if need be.
# Default value is `5mb`.
#max_body_size = "5mb"

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

# aah provides `Content Negotiation` feature for the incoming HTTP request.
# Read more about implementation and RFC details here GitHub #75.
# Perfect for REST API, also can be used for web application too if needed.
content_negotiation {
# To enable Content Negotiation for the application.
# Default value is `false`.
#enable = true

# For example: Client sends Content-Type header as `application/xml`.
# However server only supports JSON payload as request body.
# Then server responds with 415 Unsupported Media Type.
# Default value is empty list and disabled.
#accepted = ["application/json", "text/json"]

# For example: Client sends Accept header as `application/xml`.
# However server only supports serving JSON i.e. `application/json`.
# Then server responds with 406 Not Acceptable.
# Default value is empty list and disabled.
#offered = ["application/json", "text/json"]
}

# Auto Bind configuration used to bind request parameters to controller
# action parameters.
auto_bind {
# Priority is used to select the bind source priority.
# P -> Path Parameter
# F -> Form Parameter
# Q -> Query Parameter
#
# For example: Let's say you have a controller action named `OrderInfo` and its has
# parameter called `orderId`. So framework tries to parse and bind based
# on the priority. The `orderId` present in `Path` and `Form`, framework
# binds the value from `Path`. Typically recommended to have unique names
# in the request parameter though :)
# Path -> Form -> Query
# If not found then it returns with default Go zero value.
#
# Default value is `PFQ`.
#priority = "PFQ"

# Tag Name is used for bind values to struct exported fields.
# Default value is `bind`.
#tag_name = "bind"
}
}

{{ if eq .AppType "web" -}}
# ---------------------------------------------------------------
# i18n configuration
# Doc: https://docs.aahframework.org/app-config.html#section-i18n
Expand All @@ -176,18 +236,22 @@ i18n {
# Default value is `lang`.
#query = "locale"
}
}
}{{ end }}

# -----------------------------------------------------------------
# Format configuration
# Doc: https://docs.aahframework.org/app-config.html#section-format
# -----------------------------------------------------------------
format {
# Default value is `2006-01-02`.
#date = "2006-01-02"

# Default value is `2006-01-02 15:04:05`.
#datetime = "2006-01-02 15:04:05"
# 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"
]
}

# ------------------------------------------------------------------
Expand Down
20 changes: 10 additions & 10 deletions aah/app-template/config/routes.conf.atmpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ domains {
# Default value is empty string.
#default_auth = ""

# Mapping your custom `NotFound` implementation. It is when no matching
# route is found. If it is not set framework default is called. This is optional one.
# Create your controller and action method with param called `isStatic bool`.
# Framework tells you whether route is `static route` or `application route`.
#not_found {
# controller = "App"
# action = "NotFound"
#}

{{ if eq .AppType "web" -}}
#----------------------------------------------------------------------------
# Static Routes Configuration
Expand Down Expand Up @@ -119,7 +110,7 @@ domains {
# The controller to be called for mapped URL path.
# * `controller` attribute supports with or without package prefix. For e.g.: `v1/User` or `User`
# * `controller` attribute supports both naming conventions. For e.g.: `User` or `UserController`
controller = "App"
controller = "AppController"

# The action/method name in the controller to be called for mapped URL path.
# Default values are mapped based on `HTTP` method. Refer doc for more info.
Expand All @@ -142,6 +133,15 @@ domains {
# `auth` attribute as `anonymous`.
# Default value is empty string.
#auth = ""

# Max request body size for this route. If its happen to be `MultipartForm`
# then this value ignored since `request.multipart_size` config from `aah.conf`
# is applied.
#
# If this value is not provided then global `request.max_body_size` config
# from `aah.conf` is applied. So use it for specific cases.
# No default value, global value is applied.
#max_body_size = "5mb"
}

} # end - routes
Expand Down
Loading

0 comments on commit c4aa79e

Please sign in to comment.