Skip to content

Instantly share code, notes, and snippets.

@aruiz
Last active January 4, 2016 20:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aruiz/8671749 to your computer and use it in GitHub Desktop.
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
Copy link

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