router

package
v1.40.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package router provides a simple HTTP router with wildcard path suffix matching.

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 is a simple HTTP request router that matches requests based on HTTP method and path suffix patterns with wildcard support.

func New

func New() *Router

New creates a new Router instance.

func (*Router) Fallback

func (rt *Router) Fallback(handler http.Handler)

Fallback registers a handler for all other requests that don't match specific routes.

func (*Router) GetInfoRefs

func (rt *Router) GetInfoRefs(handler http.Handler)

GetInfoRefs registers a handler for GET requests ending with /info/refs. This matches patterns like: /repo/path/info/refs, /any/path/info/refs, etc.

func (*Router) PostGitUploadPack

func (rt *Router) PostGitUploadPack(handler http.Handler)

PostGitUploadPack registers a handler for POST requests ending with /git-upload-pack. This matches patterns like: /repo/path/git-upload-pack, /any/path/git-upload-pack, etc.

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface. It routes requests based on HTTP method and path suffix patterns.

Note: Protocol validation (Git Protocol v2) should be applied via middleware and is not enforced by the router itself. This allows the router to be used for both Git protocol routes (which require protocol headers) and API routes (which don't).

Jump to

Keyboard shortcuts

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