routes.go 850 B

123456789101112131415161718192021222324252627
  1. package routes
  2. import (
  3. "byom-infra-api/handlers"
  4. "byom-infra-api/middleware"
  5. "github.com/gorilla/mux"
  6. )
  7. // SetupRoutes configures all the routes for the application
  8. func SetupRoutes(r *mux.Router, dnshandler *handlers.DNSHandler) {
  9. // Add logging middleware
  10. r.Use(middleware.LoggingMiddleware)
  11. // SSH Key routes
  12. r.HandleFunc("/sshkey", GetSSHKeys).Methods("GET")
  13. r.HandleFunc("/sshkey/{id}", GetSSHKeyByID).Methods("GET")
  14. r.HandleFunc("/sshkey", CreateSSHKey).Methods("POST")
  15. r.HandleFunc("/sshkey/{id}", DeleteSSHKey).Methods("DELETE")
  16. // DNS routes
  17. r.HandleFunc("/dns", dnshandler.ListDNSRecords).Methods("GET")
  18. r.HandleFunc("/dns/{subdomain}", dnshandler.GetDNSRecordID).Methods("GET")
  19. r.HandleFunc("/dns", dnshandler.CreateDNSRecord).Methods("POST")
  20. r.HandleFunc("/dns/{id}", dnshandler.DeleteDNSRecord).Methods("DELETE")
  21. }