Create a gist now

Instantly share code, notes, and snippets.

@aruiz /go-test.go
Last active Jan 4, 2016

What would you like to do?
package main
import (
type MyHandler struct {
payload []byte
func (hdlr MyHandler) ServeHTTP (w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/json")
w.Write (hdlr.payload)
func main() {
b, err := ioutil.ReadFile("test.json")
if err != nil { panic(err) }
hdlr := MyHandler{}
hdlr.payload = b
err = http.ListenAndServe("", hdlr)
if err != nil { log.Fatal(err) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment