Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package main
import (
"log"
"net/http"
"io/ioutil"
)
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
log.Printf("Listening https://0.0.0.0:8088/")
err = http.ListenAndServeTLS("0.0.0.0:8088", "test.crt", "test.key", hldr)
if err != nil { log.Fatal(err) }
}

mkinney commented Feb 1, 2014

Correction: s/hldr/hdlr/
err = http.ListenAndServeTLS("0.0.0.0:8088", "test.crt", "test.key", hdlr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment