Update to version 8.5.5

Former-commit-id: b5be58709f17758a8df3ebc99270b97ccd8b18f2
This commit is contained in:
kataras 2017-11-02 05:50:56 +02:00
parent 6607008054
commit 666bcacf20
97 changed files with 38154 additions and 38162 deletions

View File

@ -58,7 +58,7 @@ All features of Sundown are supported, including:
// Cache is a good and a must-feature on static content, i.e "about page" or for a whole blog site. // Cache is a good and a must-feature on static content, i.e "about page" or for a whole blog site.
func main() { func main() {
app := iris.New() app := iris.New()
app.Logger().SetLevel("debug")
app.Get("/", cache.Handler(10*time.Second), writeMarkdown) app.Get("/", cache.Handler(10*time.Second), writeMarkdown)
// saves its content on the first request and serves it instead of re-calculating the content. // saves its content on the first request and serves it instead of re-calculating the content.
// After 10 seconds it will be cleared and resetted. // After 10 seconds it will be cleared and resetted.

View File

@ -14,8 +14,6 @@ func main() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
// use different go routines to sync the database
db.Async(true)
// close and unlock the database when control+C/cmd+C pressed // close and unlock the database when control+C/cmd+C pressed
iris.RegisterOnInterrupt(func() { iris.RegisterOnInterrupt(func() {
@ -44,7 +42,7 @@ func main() {
s.Set("name", "iris") s.Set("name", "iris")
//test if setted here //test if setted here
ctx.Writef("All ok session setted to: %s", s.GetString("name")) ctx.Writef("All ok session value of the 'name' is: %s", s.GetString("name"))
}) })
app.Get("/set/{key}/{value}", func(ctx iris.Context) { app.Get("/set/{key}/{value}", func(ctx iris.Context) {
@ -54,14 +52,14 @@ func main() {
s.Set(key, value) s.Set(key, value)
// test if setted here // test if setted here
ctx.Writef("All ok session setted to: %s", s.GetString(key)) ctx.Writef("All ok session value of the '%s' is: %s", key, s.GetString(key))
}) })
app.Get("/get", func(ctx iris.Context) { app.Get("/get", func(ctx iris.Context) {
// get a specific key, as string, if no found returns just an empty string // get a specific key, as string, if no found returns just an empty string
name := sess.Start(ctx).GetString("name") name := sess.Start(ctx).GetString("name")
ctx.Writef("The name on the /set was: %s", name) ctx.Writef("The 'name' on the /set was: %s", name)
}) })
app.Get("/get/{key}", func(ctx iris.Context) { app.Get("/get/{key}", func(ctx iris.Context) {
@ -91,5 +89,5 @@ func main() {
sess.ShiftExpiration(ctx) sess.ShiftExpiration(ctx)
}) })
app.Run(iris.Addr(":8080")) app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithoutVersionChecker)
} }

View File

@ -11,8 +11,6 @@ import (
func main() { func main() {
db, _ := boltdb.New("./sessions/sessions.db", 0666, "users") db, _ := boltdb.New("./sessions/sessions.db", 0666, "users")
// use different go routines to sync the database
db.Async(true)
// close and unlock the database when control+C/cmd+C pressed // close and unlock the database when control+C/cmd+C pressed
iris.RegisterOnInterrupt(func() { iris.RegisterOnInterrupt(func() {

View File

@ -5,19 +5,19 @@ import (
"github.com/kataras/iris" "github.com/kataras/iris"
"github.com/gorilla/securecookie"
"github.com/kataras/iris/sessions" "github.com/kataras/iris/sessions"
"github.com/kataras/iris/sessions/sessiondb/file" "github.com/kataras/iris/sessions/sessiondb/file"
) )
func main() { func main() {
db, _ := file.New("./sessions/", 0666) db, _ := file.New("./sessions/", 0755)
// use different go routines to sync the database
db.Async(true)
sess := sessions.New(sessions.Config{ sess := sessions.New(sessions.Config{
Cookie: "sessionscookieid", Cookie: "sessionscookieid",
Expires: 45 * time.Minute, // <=0 means unlimited life Expires: 24 * time.Hour, // <=0 means unlimited life
Encoding: securecookie.New([]byte("C2O6J6oYTd0CBCNERkWZK8jGOXTXf9X2"),
[]byte("UTp6fJsicraGxA2cslELrrLX7msg5jfE")),
}) })
// //
@ -84,5 +84,5 @@ func main() {
sess.ShiftExpiration(ctx) sess.ShiftExpiration(ctx)
}) })
app.Run(iris.Addr(":8080")) app.Run(iris.Addr(":8080"), iris.WithoutVersionChecker)
} }

View File

@ -12,9 +12,6 @@ import (
func main() { func main() {
db, _ := leveldb.New("./sessions/") db, _ := leveldb.New("./sessions/")
// use different go routines to sync the database
db.Async(true)
// close and unlock the database when control+C/cmd+C pressed // close and unlock the database when control+C/cmd+C pressed
iris.RegisterOnInterrupt(func() { iris.RegisterOnInterrupt(func() {
db.Close() db.Close()

View File

@ -22,8 +22,6 @@ func main() {
IdleTimeout: service.DefaultRedisIdleTimeout, IdleTimeout: service.DefaultRedisIdleTimeout,
Prefix: ""}) // optionally configure the bridge between your redis server Prefix: ""}) // optionally configure the bridge between your redis server
// use go routines to query the database
db.Async(true)
// close connection when control+C/cmd+C // close connection when control+C/cmd+C
iris.RegisterOnInterrupt(func() { iris.RegisterOnInterrupt(func() {
db.Close() db.Close()

View File

@ -91,6 +91,13 @@ const (
Favicon = "favicon.ico" Favicon = "favicon.ico"
) )
// Configure accepts configurations and runs them inside the Bootstraper's context.
func (b *Bootstrapper) Configure(cs ...Configurator) {
for _, c := range cs {
c(b)
}
}
// Bootstrap prepares our application. // Bootstrap prepares our application.
// //
// Returns itself. // Returns itself.

View File

@ -6,15 +6,9 @@ import (
"github.com/kataras/iris/_examples/structuring/bootstrap/routes" "github.com/kataras/iris/_examples/structuring/bootstrap/routes"
) )
var app = bootstrap.New("Awesome App", "kataras2006@hotmail.com",
identity.Configure,
routes.Configure,
)
func init() {
app.Bootstrap()
}
func main() { func main() {
app := bootstrap.New("Awesome App", "kataras2006@hotmail.com")
app.Bootstrap()
app.Configure(identity.Configure, routes.Configure)
app.Listen(":8080") app.Listen(":8080")
} }