Categorygithub.com/vulpine-io/midl
repository
1.2.2
Repository: https://github.com/vulpine-io/midl.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

= midl

image:https://img.shields.io/github/license/vulpine-io/midl.svg[MIT License] image:https://travis-ci.org/vulpine-io/midl.svg?branch=master[Build Status,link=https://travis-ci.org/vulpine-io/midl] image:https://img.shields.io/codecov/c/github/vulpine-io/midl.svg[Codecov,link=https://codecov.io/gh/vulpine-io/midl] image:https://goreportcard.com/badge/github.com/vulpine-io/midl[Go Report Card, link=https://goreportcard.com/report/github.com/vulpine-io/midl]

Serializing middleware stack for building APIs in Go.

== Example

=== Simple

[source,go]

package main

import ( "net/http" "github.com/vulpine-io/midl.v1/pkg/midl" )

func main() { http.Handle("/", midl.JSONAdapter( NewSessionHandler(), NewInputValidator(), NewController(), )) log.Fatal(http.ListenAndServe(":8080", nil)) }

=== Working demo

Example usage using the demo available in the cmd/test package.

[source,bash]

$ go run cmd/test/*.go & $ curl -iX POST -d'{}' localhost:8080/combine HTTP/1.1 400 Bad Request Content-Type: application/json Date: Tue, 29 May 2018 23:33:56 GMT Content-Length: 51

["start: start is required","end: end is required"] $ curl -iX POST -d'{"start":["a","b"], "end":["c","d"]}' localhost:8080/combine HTTP/1.1 200 OK Content-Type: application/json Custom-Header: some value Date: Tue, 29 May 2018 23:34:39 GMT Content-Length: 32

{"combos":["ac","ad","bc","bd"]}

== Testing

A full set of configurable mock implementations for every project interface is available in the gopkg.in/foxcapades/midl.v1/pkg/midlmock package.