ion: github.com/estebarb/ion Index | Files | Directories

package ion

import "github.com/estebarb/ion"

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

This framework is based on https://blog.gopheracademy.com/advent-2016/go-syntax-for-dsls/ 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

Index

Package Files

ion.go

func PathEnd Uses

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 Uses

type Builder interface {
    Build() http.Handler
}

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

type Chain Uses

type Chain []Middleware

Chain describes a secuence of Middleware

func (Chain) Then Uses

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 Uses

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

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

func (Endpoint) Build Uses

func (e Endpoint) Build() http.Handler

Build generates an http.Handler from an Endpoint

type Methods Uses

type Methods map[string]Endpoint

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

func (Methods) Build Uses

func (m Methods) Build() http.Handler

Build generates an http.Handler

type Middleware Uses

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 Uses

type Routes map[string]Endpoint

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

func (Routes) Build Uses

func (r Routes) Build() http.Handler

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

Directories

PathSynopsis
components/resource
components/routerPackage router contains a flexible router, with integrated context management per request
examples/hello
futuresPackage futures allow adding incomplete computations in contexts and templates.
middlewarePackage middleware contains general purpose middleware.
middleware/hotcachePackage hotcache intercepts and group equal requests, perform a single server request.

Package ion imports 4 packages (graph) and is imported by 2 packages. Updated 2020-05-23. Refresh now. Tools for package owners.