Example #1
0
func handleAll(mux *pat.PatternServeMux, pattern string, handler http.Handler) {
	mux.Get(pattern, handler)
	mux.Post(pattern, handler)
	mux.Head(pattern, handler)
	mux.Put(pattern, handler)
	mux.Del(pattern, handler)
	mux.Options(pattern, handler)
}
Example #2
0
func (self *HttpServer) registerEndpoint(p *pat.PatternServeMux, method string, pattern string, f libhttp.HandlerFunc) {
	switch method {
	case "get":
		p.Get(pattern, CorsHeaderHandler(f))
	case "post":
		p.Post(pattern, CorsHeaderHandler(f))
	case "del":
		p.Del(pattern, CorsHeaderHandler(f))
	}
	p.Options(pattern, CorsHeaderHandler(self.sendCrossOriginHeader))
}
Example #3
0
func (self *HttpServer) registerEndpoint(p *pat.PatternServeMux, method string, pattern string, f libhttp.HandlerFunc) {
	version := self.clusterConfig.GetLocalConfiguration().Version
	switch method {
	case "get":
		p.Get(pattern, HeaderHandler(f, version))
	case "post":
		p.Post(pattern, HeaderHandler(f, version))
	case "del":
		p.Del(pattern, HeaderHandler(f, version))
	}
	p.Options(pattern, HeaderHandler(self.sendCrossOriginHeader, version))
}
Example #4
0
func AddHandlers(m *pat.PatternServeMux, base string) {

	// Movies
	m.Get(base+"/movies", JsonHandler(MovieList))
	m.Get(base+"/movies/:id", JsonHandler(MovieShow))
	m.Put(base+"/movies", JsonHandler(MovieCreate))
	m.Del(base+"/movies/:id", JsonHandler(MovieDelete))

	// Libraries
	m.Get(base+"/libraries", JsonHandler(LibraryList))
	m.Get(base+"/libraries/:id", JsonHandler(LibraryShow))
	m.Put(base+"/libraries", JsonHandler(LibraryCreate))
	m.Del(base+"/libraries/:id", JsonHandler(LibraryDelete))
	m.Get(base+"/libraries/:id/process", JsonHandler(LibraryProcess))

	// Series
	m.Get(base+"/series", JsonHandler(SeriesList))
	m.Get(base+"/series/:id", JsonHandler(SeriesShow))
	m.Put(base+"/series", JsonHandler(SeriesCreate))
	m.Del(base+"/series/:id", JsonHandler(SeriesDelete))

	// Series season
	m.Get(base+"/series/:id/seasons", JsonHandler(SeasonsList))

	// Series Episodes
	m.Get(base+"/series/:series_id/seasons/:season_num/episodes", JsonHandler(EpisodeList))

	// Episode
	m.Get(base+"/episodes/:id", JsonHandler(EpisodeShow))
	m.Put(base+"/episodes", JsonHandler(EpisodeCreate))
	m.Del(base+"/episodes/:id", JsonHandler(EpisodeDelete))
	m.Get(base+"/series/:id/episodes", JsonHandler(SeriesEpisodeList))
}
Example #5
0
func AddHandlers(m *pat.PatternServeMux, base string) {

	// Movies
	m.Get(base+"/movies", JsonHandler(MovieList))
	m.Get(base+"/movies/:id", JsonHandler(MovieShow))
	m.Put(base+"/movies", JsonHandler(MovieCreate))
	m.Del(base+"/movies/:id", JsonHandler(MovieDelete))

	// Libraries
	m.Get(base+"/libraries", JsonHandler(LibraryList))
	m.Get(base+"/libraries/:id", JsonHandler(LibraryShow))
	m.Put(base+"/libraries", JsonHandler(LibraryCreate))
	m.Del(base+"/libraries/:id", JsonHandler(LibraryDelete))
}
Example #6
0
func registerEndpoint(ep apihttp.Endpoint, mux *pat.PatternServeMux) {
	switch ep.Method {
	case "GET":
		mux.Get(ep.Pattern, ep.Handler)
	case "POST":
		mux.Post(ep.Pattern, ep.Handler)
	case "HEAD":
		mux.Head(ep.Pattern, ep.Handler)
	case "PUT":
		mux.Put(ep.Pattern, ep.Handler)
	case "DEL":
		mux.Del(ep.Pattern, ep.Handler)
	case "OPTIONS":
		mux.Options(ep.Pattern, ep.Handler)
	}
}