urlparse

package module
v0.0.0-...-6a114b0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: GPL-2.0 Imports: 3 Imported by: 0

README

go-urlparse

Go URL parsing package

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainsSubPathsErr

type ContainsSubPathsErr struct{}

ContainsSubPathsErr is returned, when SubPaths are present in the URL (unspecified Elements)

func (ContainsSubPathsErr) Error

func (e ContainsSubPathsErr) Error() string

type Element

type Element struct {
	Key   string // Element key
	Order int    // Order of the element in URL Resource Schema
}

Element is an identifier before the value (eg. /users/john, where "users" is the element and "john" is the value)

type InvalidOrderErr

type InvalidOrderErr struct{}

InvalidOrderErr is returned, when the Element order in parsed URL is invalid

func (InvalidOrderErr) Error

func (e InvalidOrderErr) Error() string

type ResourceSchema

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

ResourceSchema contains elements that define its structure ( (Element.Key/Value) / (Element.Key/Value) / ... )

func NewResourceSchema

func NewResourceSchema() ResourceSchema

NewResourceSchema initializes ResourceSchema and returns it

func (*ResourceSchema) DisablePrecedingLevels

func (r *ResourceSchema) DisablePrecedingLevels()

DisablePrecedingLevels disables preceding level check

func (*ResourceSchema) NewElement

func (r *ResourceSchema) NewElement(key string, order int)

NewElement creates a new element

func (*ResourceSchema) Parse

func (r *ResourceSchema) Parse(url *url.URL) (map[string]string, error)

Parse the URL into ResourceSchema

func (*ResourceSchema) SetAllowSubPaths

func (r *ResourceSchema) SetAllowSubPaths(allowSubPaths bool)

SetAllowSubPaths allows Element + N-Elements

func (*ResourceSchema) SetEnforceOrder

func (r *ResourceSchema) SetEnforceOrder(enforceOrder bool)

SetEnforceOrder enforces the Element.Order spec

func (*ResourceSchema) SetPrecedingLevels

func (r *ResourceSchema) SetPrecedingLevels(precedingLevels int) error

SetPrecedingLevels sets the allowed levels before the elements

type SubPathsAllowedErr

type SubPathsAllowedErr struct{}

SubPathsAllowedErr is returned, when you try to enforce preceding levels

func (SubPathsAllowedErr) Error

func (e SubPathsAllowedErr) Error() string

Jump to

Keyboard shortcuts

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