예제 #1
0
파일: server.go 프로젝트: jelinden/selfjs
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	bundle, _ := ioutil.ReadFile("./build/bundle.js")
	http.Handle("/", selfjs.New(runtime.NumCPU(), string(bundle)))
	http.Handle("/favicon.ico", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(204)
	}))
	http.Handle("/universal.js", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "./build/bundle.js")
	}))

	http.ListenAndServe(":8080", nil)
}
예제 #2
0
func TestHandler(t *testing.T) {
	w := httptest.NewRecorder()
	r, _ := http.NewRequest("GET", "/", nil)
	selfjs.New(1, script).ServeHTTP(w, r)
	eq(t, "Hello World!\n", w.Body.String())
}