コード例 #1
0
//Setup setups handlers for 2ch interface.
func Setup(s *cgi.LoggingServeMux) {
	log.Println("start 2ch interface")
	rtr := mux.NewRouter()

	cgi.RegistToRouter(rtr, "/2ch/", boardApp)
	cgi.RegistToRouter(rtr, "/2ch/dat/{datkey:[^\\.]+}.dat", threadApp)
	cgi.RegistToRouter(rtr, "/2ch/{board:[^/]+}/subject.txt", subjectApp)
	cgi.RegistToRouter(rtr, "/2ch/subject.txt", subjectApp)
	cgi.RegistToRouter(rtr, "/2ch/{board:[^/]+}/head.txt", headApp)
	cgi.RegistToRouter(rtr, "/2ch/head.txt", headApp)
	s.Handle("/2ch/", handlers.CompressHandler(rtr))

	s.RegistCompressHandler("/test/bbs.cgi", postCommentApp)
}
コード例 #2
0
//Setup setups handlers for thread.cgi
func Setup(s *cgi.LoggingServeMux) {
	rtr := mux.NewRouter()

	cgi.RegistToRouter(rtr, cfg.ThreadURL+"/", printThreadIndex)

	reg := cfg.ThreadURL + "/{datfile:thread_[0-9A-F]+}/{id:[0-9a-f]{32}}/s{stamp:\\d+}.{thumbnailSize:\\d+x\\d+}.{suffix:.*}"
	cgi.RegistToRouter(rtr, reg, printAttach)

	reg = cfg.ThreadURL + "/{datfile:thread_[0-9A-F]+}/{id:[0-9a-f]{32}}/{stamp:\\d+}.{suffix:.*}"
	cgi.RegistToRouter(rtr, reg, printAttach)

	reg = cfg.ThreadURL + "/{path:[^/]+}{end:/?$}"
	cgi.RegistToRouter(rtr, reg, printThread)

	reg = cfg.ThreadURL + "/{path:[^/]+}/{id:[0-9a-f]{8}}{end:$}"
	cgi.RegistToRouter(rtr, reg, printThread)

	reg = cfg.ThreadURL + "/{path:[^/]+}/p{page:[0-9]+}{end:$}"
	cgi.RegistToRouter(rtr, reg, printThread)

	s.Handle(cfg.ThreadURL+"/", handlers.CompressHandler(rtr))
}