routing.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. GNU GENERAL PUBLIC LICENSE
  3. Version 3, 29 June 2007
  4. Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
  5. Everyone is permitted to copy and distribute verbatim copies
  6. of this license document, but changing it is not allowed.
  7. http-wokou, An HTTP Proxying framework for bypassing DNS Security
  8. Copyright (C) 2024 Russell Hrubesky, ChiralWorks Software LLC
  9. This program is free software: you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation, either version 3 of the License, or
  12. (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. package httpserver
  21. import (
  22. "os"
  23. "os/signal"
  24. "syscall"
  25. "github.com/gin-gonic/gin"
  26. )
  27. /*
  28. Registers the exposed route to utilize the handler function
  29. :param e: pointer to a gin.Engine struct
  30. :param cfg: pointer to an HttpServerConfig struct
  31. */
  32. func RegisterRoutes(e *gin.Engine, cfg *HttpServerConfig, rmaps *RouteMap) {
  33. c := NewController(cfg, rmaps)
  34. sigChanel := make(chan os.Signal)
  35. signal.Notify(sigChanel, os.Interrupt, syscall.SIGINT)
  36. go func(core *Controller) {
  37. <-sigChanel
  38. c.RouteMaps.ExportRouteMap(c.Config.RouteMapPath)
  39. os.Exit(1)
  40. }(c)
  41. web := e.Group("")
  42. web.Any("/*ProxiedPath", c.HandleAny)
  43. }