middleware/

directory
v0.0.0-...-aeb31df Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2016 License: BSD-3-Clause

README

Middleware

Iris has it's build'n small middleware(s) here

Structure

All Iris build'n middleware(s) belong here, to this folder 'iris/middleware'* middleware is also the package name.

Each middleware must be written to it's own folder.


How to write

Simple, Import iris and use it to the middleware

import (
	iris "github.com/kataras/iris"
)

Notice: We recommend that each middleware exports only one Function which returns an object that implements the iris.Handler (func Serve(ctx *iris.Context){}). Look here for an example


How to use a middleware


package main

import (
	"github.com/kataras/iris"
	"github.com/kataras/iris/middleware/gzip"
)

type Page struct {
	Title string
}

func main() {
	iris.Templates("./_examples/compression_gzip/templates/*.html")
	
	// here is how to use a middleware
	iris.Use(gzip.Gzip(gzip.DefaultCompression))
	
	iris.Get("/public/*static", iris.Static("./_examples/compression_gzip/static/", "/public/"))

	iris.Get("/", func(c *iris.Context) {
		c.RenderFile("index.html", Page{"My Index Title"})
	})

	iris.Listen(":8080")
}

Directories

Path Synopsis
Cors credits goes to @keuller
Cors credits goes to @keuller

Jump to

Keyboard shortcuts

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