paths

package
v0.0.0-...-86643de Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: BSD-2-Clause Imports: 7 Imported by: 12

Documentation

Overview

The paths package provides capabilities for working with paths, which is a key part of Goweb. Advanced users should use the paths package if they are writing their own Handler implementations.

Index

Constants

View Source
const FileExtensionSeparator string = "."
View Source
const MatchAllPaths string = segmentCatchAll
View Source
const PathSeperator string = "/"

Variables

This section is empty.

Functions

func PathFromSegments

func PathFromSegments(segments ...interface{}) string

PathFromSegments turns the arguments into a path string.

func PathPrefixForClass

func PathPrefixForClass(controller interface{}) string

PathPrefixForClass gets the path prefix by reflecting on the name of the class of the specified object.

E.g.

LovelyPeopleController == "lovely-people"

Types

type Path

type Path struct {
	// RawPath is the original raw string of this path.
	RawPath string
	// contains filtered or unexported fields
}

Path represents the path segment of a URL.

func NewPath

func NewPath(rawPath string) *Path

NewPath creates a new Path with the given raw string.

func (*Path) RealFilePath

func (p *Path) RealFilePath(systemPath, urlPath string) string

RealFilePath gets the real file path by assuming the current path is the public prefix, the urlPath is the actual request and the systemPath is the physical location where those files live.

func (*Path) Segments

func (p *Path) Segments() []string

Segments gets the segments for this path broken up by the PathSeparator.

type PathMatch

type PathMatch struct {
	Matches    bool
	Parameters objx.Map
}

PathMatch holds details about whether a path matches a PathPattern or not.

If it does match, the Parameters map will contain the values for any dynamic parameters discovered.

var PathDoesntMatch *PathMatch = new(PathMatch)

PathDoesntMatch is a special instance of PathMatch that indicates the paths do not match.

type PathPattern

type PathPattern struct {

	// RawPath is the raw path.
	RawPath string
	// contains filtered or unexported fields
}

PathPattern represents a path that can contain special matching segments.

Valid paths include:

  /*** - Matches everything
	/*** /literal/ *** - match anything before and after literal
  /literal
  /{placeholder}
  /[optional placeholder]
  /* - matches like a placeholder but doesn't care what it is
  /something/*** - Matches the start plus anything after it

func NewPathPattern

func NewPathPattern(path string) (*PathPattern, error)

func (*PathPattern) GetPathMatch

func (p *PathPattern) GetPathMatch(path *Path) *PathMatch

GetPathMatch gets the PathMatch object describing the match or otherwise between this PathPattern and the specified Path.

func (*PathPattern) String

func (p *PathPattern) String() string

Jump to

Keyboard shortcuts

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