Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created November 11, 2015 09:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuroyoro/5e3726e132a4bffe31e2 to your computer and use it in GitHub Desktop.
Save yuroyoro/5e3726e132a4bffe31e2 to your computer and use it in GitHub Desktop.
Goでhttp2 server
package main
import (
"fmt"
"golang.org/x/net/http2"
"log"
"net/http"
)
func main() {
var s http.Server
http2.VerboseLogs = true
s.Addr = ":9090"
http2.ConfigureServer(&s, nil)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=UTF-8")
fmt.Fprintln(w, "( ;゚皿゚) オマエをhttp2")
})
log.Fatal(s.ListenAndServeTLS("server.crt", "server.key"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment