1
0
mirror of https://github.com/kataras/iris.git synced 2026-02-28 05:26:00 +00:00

publish v12.2.0-alpha6

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-02-18 22:19:33 +02:00
parent 4899fe95f4
commit 41026c9209
21 changed files with 984 additions and 284 deletions

View File

@@ -93,6 +93,7 @@
* [The CSV Formatter](logging/request-logger/accesslog-csv/main.go)
* [Create your own Formatter](logging/request-logger/accesslog-formatter/main.go)
* [Root and Proxy AccessLog instances](logging/request-logger/accesslog-proxy/main.go)
* [Slack integration example](logging/request-logger/accesslog-slack/main.go)
* API Documentation
* [Yaag](apidoc/yaag/main.go)
* [Swagger](https://github.com/iris-contrib/swagger/tree/master/_examples/basic)

View File

@@ -0,0 +1,5 @@
package main
func main() {
println("Navigate to: https://github.com/kataras/iris/issues/1808#issuecomment-1013757925")
}

View File

@@ -0,0 +1,64 @@
package main
import (
"time"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/monitor"
)
func main() {
app := iris.New()
// Initialize and start the monitor middleware.
m := monitor.New(monitor.Options{
RefreshInterval: 2 * time.Second,
ViewRefreshInterval: 2 * time.Second,
ViewTitle: "MyServer Monitor",
})
// Manually stop monitoring on CMD/CTRL+C.
iris.RegisterOnInterrupt(m.Stop)
// Serve the actual server's process and operating system statistics as JSON.
app.Post("/monitor", m.Stats)
// Render with the default page.
app.Get("/monitor", m.View)
/* You can protect the /monitor under an /admin group of routes
with basic authentication or any type authorization and authentication system.
Example Code:
app.Post("/monitor", myProtectMiddleware, m.Stats)
app.Get("/monitor", myProtectMiddleware, m.View)
*/
/* You can also get the OS statistics using the Holder.GetStats method.
Example Code:
for {
stats := m.Holder.GetStats()
fmt.Printf("%#+v\n", stats)
time.Sleep(time.Second)
}
Note that the same stats are also stored in the expvar metrics:
- pid_cpu
- pid_ram
- pid_conns
- os_cpu
- os_ram
- os_total_ram
- os_load_avg
- os_conns
Check https://github.com/iris-contrib/middleware/tree/master/expmetric
which can be integrated with datadog or other platforms.
*/
app.Get("/", handler)
app.Listen(":8080")
}
func handler(ctx iris.Context) {
ctx.WriteString("Test Index Handler")
}

View File

@@ -16,7 +16,7 @@ type BusinessModel struct {
// NewApp returns a new application for showcasing the sessions feature.
func NewApp(sess *sessions.Sessions) *iris.Application {
app := iris.New()
app.Use(sess.Handler()) // session is always non-nil inside handlers now.
app.Use(sess.Handler()) // register the session manager on a group of routes or the root app.
app.Get("/", func(ctx iris.Context) {
session := sessions.Get(ctx) // same as sess.Start(ctx, cookieOptions...)

View File

@@ -15,23 +15,21 @@ import (
)
func newApp() *iris.Application {
app := iris.New()
cookieName := "_session_id"
// AES only supports key sizes of 16, 24 or 32 bytes.
// You either need to provide exactly that amount or you derive the key from what you type in.
hashKey := securecookie.GenerateRandomKey(64)
blockKey := securecookie.GenerateRandomKey(32)
s := securecookie.New(hashKey, blockKey)
mySessions := sessions.New(sessions.Config{
Cookie: cookieName,
Encoding: s,
AllowReclaim: true,
})
app = example.NewApp(mySessions)
return app
// mySessions.UseDatabase(...see sessions/database example folder)
return example.NewApp(mySessions)
}
func main() {