Add new API endpoints and clean up handler interfaces: - groups/handlers.go: New lab group management API * CRUD operations for lab groups * Member management with role assignment (admin/member/viewer) * Group listing and membership queries - tokens/handlers.go: Token generation and validation endpoints * Create access tokens for public task sharing * Validate tokens for secure access * Token revocation and cleanup - routes.go: Refactor handler registration * Integrate groups handler into WebSocket routes * Remove nil parameters from all handler constructors * Cleaner dependency injection pattern - Handler interface cleanup across all modules: * jobs/handlers.go: Remove unused nil privacyEnforcer parameter * jupyter/handlers.go: Streamline initialization * scheduler/handlers.go: Consistent constructor signature * ws/handler.go: Add groups handler to dependencies
31 lines
869 B
Go
31 lines
869 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
// openAPISpecPath returns the path to the OpenAPI spec file
|
|
func openAPISpecPath() string {
|
|
// Get the directory of this source file
|
|
_, filename, _, _ := runtime.Caller(0)
|
|
dir := filepath.Dir(filename)
|
|
// Navigate to repo root and then to api/
|
|
return filepath.Join(dir, "..", "..", "api", "openapi.yaml")
|
|
}
|
|
|
|
// ServeOpenAPISpec serves the OpenAPI specification as YAML
|
|
func ServeOpenAPISpec(w http.ResponseWriter, _ *http.Request) {
|
|
specPath := openAPISpecPath()
|
|
// #nosec G304 -- specPath is a hardcoded relative path, not from user input
|
|
data, err := os.ReadFile(specPath)
|
|
if err != nil {
|
|
http.Error(w, "Failed to read OpenAPI spec", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/yaml")
|
|
w.WriteHeader(http.StatusOK)
|
|
_, _ = w.Write(data)
|
|
}
|