Back to

package ion

v0.0.0 (7f80b07)
Latest Go to latest
Published: Apr 9, 2020 | License: MIT | Module:


Package ion implements a small web framework that allows to easily connect reusable components.

This framework is based on idea of using a DSL. This approach naturally removes the need to implement a router, allowing the framework to just reuse Go standard mux.

Ion have the following features:

- Can use easily any http.Handler or http.HandlerFunc - Easily describe paths (with arguments) and method handlers - Compatible with Middlewares - Use context for passing path arguments


func PathEnd

func PathEnd(handler http.Handler) http.Handler

PathEnd is a middleware used to "cut" the requests path at the current level. The request is handled if the path is "/" or "".

type Builder

type Builder interface {
	Build() http.Handler

Builder interface is implemented by objects that can be build into an http.Handler

type Chain

type Chain []Middleware

Chain describes a secuence of Middleware

func (Chain) Then

func (c Chain) Then(h http.Handler) http.Handler

Then composes all the middlewares wrapping the given http.Handler, and returns a new http.Handler

type Endpoint

type Endpoint struct {
	Middleware  []Middleware
	Handler     Builder
	HttpHandler http.Handler

Endpoint describes a http request handler, that may have optional Middleware

func (Endpoint) Build

func (e Endpoint) Build() http.Handler

Build generates an http.Handler from an Endpoint

type Methods

type Methods map[string]Endpoint

Methods implement an http.Handler that handles requests according to the request method.

func (Methods) Build

func (m Methods) Build() http.Handler

Build generates an http.Handler

type Middleware

type Middleware func(next http.Handler) http.Handler

Middleware is a function that wrap an http.Handler and returns a value that implements the http.Handler interface

type Routes

type Routes map[string]Endpoint

Routes describe a request router that handles request according to its path

func (Routes) Build

func (r Routes) Build() http.Handler

Build returns an http.Handler that can handle requests by path

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier