Skip to content

roncohen/faye-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Faye + Go

Experimental

Usage

package main

import (
	"github.com/roncohen/faye-go"
	"github.com/roncohen/faye-go/adapters"
	"log"
	"net/http"
)

func OurLoggingHandler(pattern string, h http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		log.Printf("%v: %+v", pattern, *r.URL)
		h.ServeHTTP(w, r)
	})
}

func main() {
	fayeServer := faye.NewServer(faye.NewEngine())
	http.Handle("/faye", adapters.FayeHandler(fayeServer))

	// Also serve up some static files and show off 
	// the wonderful go http handler chain
	http.Handle("/", OurLoggingHandler("/", http.FileServer(http.Dir("src/github.com/roncohen/faye-test/static"))))

	err := http.ListenAndServe(":8000", nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages