github.com/naoina/kocha@v0.7.1-0.20171129072645-78c7a531f799/cmd/kocha-new/skeleton/new/config/app.go.tmpl (about)

     1  package config
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"runtime"
     7  	"time"
     8  
     9  	"github.com/naoina/kocha"
    10  	"github.com/naoina/kocha/log"
    11  )
    12  
    13  var (
    14  	AppName   = "{{.appName}}"
    15  	AppConfig = &kocha.Config{
    16  		Addr:          kocha.Getenv("KOCHA_ADDR", "127.0.0.1:9100"),
    17  		AppPath:       rootPath,
    18  		AppName:       AppName,
    19  		DefaultLayout: "app",
    20  		Template: &kocha.Template{
    21  			PathInfo: kocha.TemplatePathInfo {
    22  				Name: AppName,
    23  				Paths: []string{
    24  					filepath.Join(rootPath, "app", "view"),
    25  				},
    26  			},
    27  			FuncMap: kocha.TemplateFuncMap{},
    28  		},
    29  
    30  		// Logger settings.
    31  		Logger: &kocha.LoggerConfig{
    32  			Writer: os.Stdout,
    33  			Formatter: &log.LTSVFormatter{},
    34  			Level: log.INFO,
    35  		},
    36  
    37  		// Middlewares.
    38  		Middlewares: []kocha.Middleware{
    39  			&kocha.RequestLoggingMiddleware{},
    40  			&kocha.PanicRecoverMiddleware{},
    41  			&kocha.FormMiddleware{},
    42  			&kocha.SessionMiddleware{
    43  				Name: "{{.appName}}_session",
    44  				Store: &kocha.SessionCookieStore{
    45  					// AUTO-GENERATED Random keys. DO NOT EDIT.
    46  					SecretKey:  {{.secretKey}},
    47  					SigningKey: {{.signedKey}},
    48  				},
    49  
    50  				// Expiration of session cookie, in seconds, from now.
    51  				// Persistent if -1, For not specify, set 0.
    52  				CookieExpires: time.Duration(90) * time.Hour * 24,
    53  
    54  				// Expiration of session data, in seconds, from now.
    55  				// Perssitent if -1, For not specify, set 0.
    56  				SessionExpires: time.Duration(90) * time.Hour * 24,
    57  				HttpOnly:       false,
    58  			},
    59  			&kocha.FlashMiddleware{},
    60  			&kocha.DispatchMiddleware{},
    61  		},
    62  
    63  		MaxClientBodySize: 1024 * 1024 * 10, // 10MB
    64  	}
    65  
    66  	_, configFileName, _, _ = runtime.Caller(0)
    67  	rootPath                = filepath.Dir(filepath.Join(configFileName, ".."))
    68  )