iris

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package iris is a helper package to get an Iris compatible middleware.

Example (IrisMiddleware)

IrisMiddleware shows how you would create a default middleware factory and use it to create an Iris compatible middleware.

// Create our middleware factory with the default settings.
mdlw := middleware.New(middleware.Config{
	Recorder: metrics.NewRecorder(metrics.Config{}),
})

// Create our Iris Application instance.
app := iris.New()

// Add our handler and middleware
h := func(ctx iris.Context) {
	ctx.WriteString("Hello world") // nolint: errcheck
}
app.Get("/", irismiddleware.Handler("", mdlw), h)

// Serve metrics from the default prometheus registry.
log.Printf("serving metrics at: %s", ":8081")
go func() {
	_ = http.ListenAndServe(":8081", promhttp.Handler())
}()

// Serve our handler.
log.Printf("listening at: %s", ":8080")
if err := app.Listen(":8080", iris.WithOptimizations); err != nil {
	log.Panicf("error while serving: %s", err)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(handlerID string, m middleware.Middleware) iris.Handler

Handler returns a Iris measuring middleware.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL