web_service_container.go 1.2 KB

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