• Stars
    star
    39
  • Rank 693,563 (Top 14 %)
  • Language
    Go
  • Created over 9 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go net/http handler to transparently manage posted JSON

Go JSON handler godoc license build

FormJSON is a net/http handler implementing content negotiation for posted data in order to transparently expose posted JSON as if it was application/x-www-form-urlencoded. The posted data is then available using built-in r.FormValue("key")'s http.Request method.

To match capabilities of application/x-www-form-urlencoded, only single depth JSON object with string as keys and values is supported.

Usage

package main

import (
    "net/http"
    "fmt"

    "github.com/rs/formjson"
)

func main() {
    h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        body := fmt.Sprintf("Hello %s!", r.FormValue("name"))
        w.Write([]byte(body))
    })

    handler := formjson.Handler(h)
    http.ListenAndServe(":8080", handler)
}

Then this request:

curl -H "Content-Type:application/json" -d '{"name":"World"}' :8080

is now equivalent to this one:

curl -d name=World :8080

Licenses

All source code is licensed under the MIT License.

More Repositories

1

zerolog

Zero Allocation JSON Logger
Go
10,343
star
2

xid

xid is a globally unique id generator thought for the web
Go
3,874
star
3

curlie

The power of curl, the ease of use of httpie.
Go
2,808
star
4

cors

Go net/http configurable handler to handle CORS requests
Go
2,625
star
5

rest-layer

REST Layer, Go (golang) REST API framework
Go
1,257
star
6

SDSegmentedControl

A drop-in remplacement for UISegmentedControl that mimic iOS 6 AppStore tab controls
Objective-C
1,200
star
7

pushd

Blazing fast multi-protocol mobile and web push notification service
CoffeeScript
1,162
star
8

jplot

iTerm2 expvar/JSON monitoring tool
Go
1,140
star
9

SDAVAssetExportSession

AVAssetExportSession drop-in replacement with customizable audio&video settings
Objective-C
800
star
10

SDURLCache

URLCache subclass with on-disk cache support on iPhone/iPad
Objective-C
798
star
11

SafariTabSwitching

A SIMBL plugin for Safari 5.1 allowing tab switching by index (using Cmd-1, Cmd-2…)
Objective-C
472
star
12

jaggr

JSON Aggregation CLI
Go
460
star
13

SafariOmnibar

Safari plugin to add Chrome like omnibar in Safari
Objective-C
416
star
14

dnstrace

DNS resolution tracing tool
Go
270
star
15

dnscache

DNS lookup cache for Go
Go
267
star
16

node-netmask

Parse and lookup IP network blocks
CoffeeScript
253
star
17

xhandler

XHandler is a bridge between net/context and http.Handler
Go
233
star
18

xlog

xlog is a logger for net/context aware HTTP applications
Go
138
star
19

seamless

Seamless restart / zero-downtime deploy for Go servers
Go
107
star
20

xmux

xmux is a httprouter fork on top of xhandler (net/context aware)
Go
98
star
21

vast

Golang VAST 3.0 library
Go
83
star
22

xstats

xstats is a generic client for service instrumentation
Go
82
star
23

gls

A graphical ls command for iTerm2 with icons
Swift
78
star
24

SDNetworkActivityIndicator

Handle show/hiding of the iOS network activity indicator
Objective-C
75
star
25

zkfarmer

ZkFarmer is a set of tools to easily manage distributed server farms using Apache ZooKeeper
Python
74
star
26

logbench

Golang logging library benchmarks
Go
69
star
27

dashplay

Easy dashboard screen management
HTML
67
star
28

SDAdvancedWebView

Add some handy features to you UIWebViews
Objective-C
49
star
29

eve-auth-jwt

Eve OAuth 2.0 JWT token validation authentication module
Python
46
star
30

domcheck

A Python library to validate the ownership of a domain using different strategies
Python
45
star
31

iris-ice

Iris keyboard build with custom case
43
star
32

scanman

ScanSnap manager for Raspberry Pi
Python
40
star
33

moquette

MQTT service dispatcher
Go
38
star
34

SDReachability

Easy to use and to embed Reachability library
Objective-C
36
star
35

golp

Go panic logger
Go
27
star
36

xaccess

Go http handler access logger
Go
20
star
37

tzsp

TaZmen Sniffer Protocol (TZSP) parser in Go
Go
20
star
38

rest-layer-mongo

REST Layer MongoDB resource storage handler
Go
18
star
39

audience-meter

Lightweight server to mesure audience of a live event
JavaScript
17
star
40

node-dnsstamp

DNS Stamp encoding/decoding library for node
TypeScript
15
star
41

net-server-mail

Extensible Perl implementation of the STMP protocol and its different evolutions (ie: ESMTP, LMTP)
Perl
15
star
42

vmap

Golang VMAP 1.0 library
Go
14
star
43

SDSRTParser

Objective-C SRT subtitle parser
Objective-C
13
star
44

mysql-genocide

Parallel operations on MySQL processlist
Perl
11
star
45

dnsdump

DNS Packet Dump
Go
10
star
46

pinba_http

Pinba HTTP Gateway
Python
8
star
47

gh-readme

Githup pages template for projects README
CSS
7
star
48

rest-layer-es

REST Layer ElasticSearch resource storage handler
Go
6
star
49

mydbd

A mysqli OO interface with PEAR::DB API compatibility
PHP
5
star
50

local-ip

Go
4
star
51

rest-layer-mem

REST Layer memory storage handler
Go
4
star
52

homebrew-tap

rs homebrew packages
Ruby
3
star
53

xlog-nsq

XLog to NSQ Output
Go
3
star
54

rest-layer-hystrix

REST Layer Hystrix storage handler wrapper
Go
3
star
55

rrdpoller

Easily query and perform threshold tests on RRD files data
Perl
3
star
56

rrdcollect-remote

Collect rrdcollect output from several hosts to update local RRD files
Perl
2
star
57

SiriDailymotion

AssistantExtensions plugin to integrate Dailymotion to Siri on Jailbroken iPhone 4s
Objective-C
2
star
58

proxy

A simple HTTP explicit forward proxy http.Handler
Go
2
star
59

gcs-oauth2-boto-env-plugin

Google Storage auth2 plugin with support for passing service key via environment
Python
2
star
60

rs.github.com

1
star
61

obfu

Go
1
star