github.com/alejandroesc/spdy@v0.0.0-20200317064415-01a02f0eb389/examples/spdy_only_server/server.go (about) 1 // Copyright 2014 Jamie Hall. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "log" 9 "net/http" 10 11 "github.com/SlyMarbo/spdy" 12 ) 13 14 func httpHandler(w http.ResponseWriter, req *http.Request) { 15 w.Header().Set("Content-Type", "text/plain") 16 w.Write([]byte("This is an example server.\n")) 17 } 18 19 func main() { 20 http.HandleFunc("/", httpHandler) 21 log.Printf("About to listen on 10443. Go to https://127.0.0.1:10443/") 22 err := spdy.ListenAndServeSpdyOnly(":10443", "cert.pem", "key.pem", nil) 23 if err != nil { 24 log.Fatal(err) 25 } 26 }