Skip to content

gota33/http-binder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example

package main

import (
	"net/http"
	"github.com/gota33/http-binder"
	"github.com/go-chi/chi/v5"
)

var b = binder.NewInput(binder.InputConfig{
	UriParamGetter: chi.URLParam,
})

func handle(w http.ResponseWriter, r *http.Request) {
	var request struct {
		H string `header:"h"`
		Q string `query:"q"`
		F string `form:"f"`
		U string `uri:"u"`
		J string `json:"j"`
		X string `xml:"x"`
	}

	if err := b.BindInput(r, &request); err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
}

About

HTTP request & response binder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages