router

package
v0.0.0-...-b3e6d50 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router handles the registration and management of routes in the application.

func New

func New() *Router

New creates and returns a new Router instance.

func (*Router) DiscoverAndRegisterRoutes

func (r *Router) DiscoverAndRegisterRoutes() error

DiscoverAndRegisterRoutes automatically discovers and registers all routes in the pages and components directories.

Returns: - error: An error if discovery or registration fails, nil otherwise.

func (*Router) RegisterRoute

func (r *Router) RegisterRoute(filePath string) error

RegisterRoute automatically registers a route based on the file name and location. It determines if it's a page or component, imports the corresponding Params struct, and sets up the route with the correct handler.

Parameters: - filePath: The path to the .templ.go file, relative to the project root.

Returns: - error: An error if registration fails, nil otherwise.

func (*Router) Run

func (r *Router) Run(addr string) error

Run starts the HTTP server and begins listening for requests.

Parameters: - addr: The address and port to listen on (e.g., ":8080").

Returns: - error: An error if the server fails to start or encounters an error while running.

Jump to

Keyboard shortcuts

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