Skip to content

Instantly share code, notes, and snippets.



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.ListenAndServeTLS("", "test.crt", "test.key", hldr)
if err != nil { log.Fatal(err) }

This comment has been minimized.

Copy link

@mkinney mkinney commented Feb 1, 2014

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

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