Help us shape the future of Go! Take the 2026 Go Developer Survey

discover

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package discover finds the routes of an application: from Laravel's route list, an OpenAPI specification, the files of a Next.js or Nuxt project, or any command that prints them as JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, root string, adapters []Adapter, fetch Fetch, log io.Writer) (*routes.Inventory, error)

Run runs every adapter from the project root and returns the inventory.

Types

type Adapter

type Adapter struct {
	Adapter  string   `yaml:"adapter"`             // laravel, openapi, nextjs, nuxt, spring, symfony, rails, django, command
	Command  []string `yaml:"command,omitempty"`   // laravel: route:list; command: prints routes as JSON
	PHP      []string `yaml:"php,omitempty"`       // laravel: runs PHP in the application, for validation rules
	File     string   `yaml:"file,omitempty"`      // openapi: specification file (JSON or YAML)
	URL      string   `yaml:"url,omitempty"`       // openapi: specification the running application serves (a path on the target or a full URL)
	Identity string   `yaml:"identity,omitempty"`  // openapi url, spring: read as this identity (some applications describe only what the caller may use)
	Target   string   `yaml:"target,omitempty"`    // the service these routes belong to, with several targets
	Dir      string   `yaml:"dir,omitempty"`       // folder of the service: commands run there, files are found there (default: the project root)
	BasePath string   `yaml:"base_path,omitempty"` // prefix of every path (Next.js basePath, an API prefix)
}

Adapter is one entry under discover: in driftgate.yaml.

func (Adapter) Validate

func (a Adapter) Validate() error

Validate checks that the adapter has what it needs.

type Fetch

type Fetch func(ctx context.Context, url, identity, target string) ([]byte, error)

Fetch reads a URL from the running application (only allowed hosts), as the identity when one is given.

Jump to

Keyboard shortcuts

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