formjson

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 10 Imported by: 0

README

#gorouter-middleware-formjson Provides "x-www-form-urlencoded" to "json" conversion middleware for go-json-rest

Explanation

This package provides a Gorouter middleware useful for converting request data with the content type "application/x-www-form-urlencoded" to "application/json"

If "Content-Type" Header set to "x-www-form-urlencoded":

  • Changes header "Content-Type" from "application/x-www-form-urlencoded" to "application/json"
  • Converts body from var1=val1&var2=val2 to {"var1":"val1","var2":"val2"}

Installation

go get github.com/mar1n3r0/gorouter-middleware-formjson

Usage

// NewRouter provides new router
func NewRouter(logger *log.Logger, server *server.Server, mysqlConnection *sql.DB, grpcConnectionMap map[string]*grpc.ClientConn) gorouter.Router {
	// Global middleware
	router := gorouter.New(
		http_form_middleware.FormJson()
	)

Documentation

Overview

Package formjson provides Middleware for converting posted x-www-form-urlencoded data into json

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormJson

func FormJson() gorouter.MiddlewareFunc

Provides "x-www-form-urlencoded" to "json" conversion middleware for gorouter

Types

type FormError

type FormError struct {
	Error   error
	Message string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL