Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Route ¶
type Route struct {
Url string // The URL path for the route (e.g., "/api/v1/resource")
Method route.MethodType // The HTTP method for the route (e.g., route.GET, route.POST)
Resource string // name of the resource represented by route
Verb string // Action of verb corresponding to this API
Scopes []string // Scope for the resource, with top level scope being first in the list and so on, empty slice indicates no scope or tenant level access
}
Route represents an HTTP route with a URL and HTTP method. The Method field uses the custom MethodType defined in the route package.
func NewRoute ¶
NewRoute creates a new Route instance from a URL and HTTP method string.
Parameters:
- url: The URL path for the route.
- method: The HTTP method as a string (e.g., "GET", "POST").
Returns:
- *Route: Pointer to the created Route struct.
The method string is mapped to the corresponding route.MethodType. If the method is unknown, it defaults to route.GET.
Usage ¶
import (
"github.com/go-core-stack/auth/model"
)
func main() {
r := model.NewRoute("/api/v1/resource", "POST")
fmt.Println(r.Url) // Output: /api/v1/resource
fmt.Println(r.Method) // Output: 1 (assuming route.POST == 1)
}
Click to show internal directories.
Click to hide internal directories.