Skip to main content


Package net/http

provides HTTP client and server implementations.


Chain httpin's Middlware to your http.Handlers. We recommend using justinas/alice to chain your middlewares.

Run Demo

package main

import (


type ListUsersInput struct {
Gender string `in:"query=gender"`
AgeRange []int `in:"query=age_range"`
IsMember bool `in:"query=is_member"`

func ListUsers(rw http.ResponseWriter, r *http.Request) {
// Retrieve you data in one line of code!
input := r.Context().Value(httpin.Input).(*ListUsersInput)

fmt.Printf("input: %#v\n", input)

func init() {
// Bind input struct with handler.
http.Handle("/users", alice.New(

func main() {
r, _ := http.NewRequest("GET", "/users?gender=male&age_range=18&age_range=24&is_member=1", nil)

rw := httptest.NewRecorder()
http.DefaultServeMux.ServeHTTP(rw, r)