1 package restful 2 3 // Copyright 2013 Ernest Micklei. All rights reserved. 4 // Use of this source code is governed by a license 5 // that can be found in the LICENSE file. 6 7 import ( 8 "net/http" 9 ) 10 11 // DefaultContainer is a restful.Container that uses http.DefaultServeMux 12 var DefaultContainer *Container 13 14 func init() { 15 DefaultContainer = NewContainer() 16 DefaultContainer.ServeMux = http.DefaultServeMux 17 } 18 19 // If set the true then panics will not be caught to return HTTP 500. 20 // In that case, Route functions are responsible for handling any error situation. 21 // Default value is false = recover from panics. This has performance implications. 22 // OBSOLETE ; use restful.DefaultContainer.DoNotRecover(true) 23 var DoNotRecover = false 24 25 // Add registers a new WebService add it to the DefaultContainer. 26 func Add(service *WebService) { 27 DefaultContainer.Add(service) 28 } 29 30 // Filter appends a container FilterFunction from the DefaultContainer. 31 // These are called before dispatching a http.Request to a WebService. 32 func Filter(filter FilterFunction) { 33 DefaultContainer.Filter(filter) 34 } 35 36 // RegisteredWebServices returns the collections of WebServices from the DefaultContainer 37 func RegisteredWebServices() []*WebService { 38 return DefaultContainer.RegisteredWebServices() 39 } 40