model

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

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

func NewRoute(url, method string) *Route

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL