routes

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LookupGalleryByName      = route("GET", "/galleries/lookup/name/{Name}")
	LookupGalleryStackByName = route("GET", "/galleries/{GalleryID}/lookup/stack-name/{Name}")
	ShowGallery              = route("GET", "/galleries/{GalleryID}")
	UploadImage              = route("POST", "/galleries/{GalleryID}/stacks")
	ReplaceImage             = route("PUT", "/galleries/{GalleryID}/stacks/{StackID}")
	UpdateStack              = route("PATCH", "/galleries/{GalleryID}/stacks/{StackID}")
	DeleteStack              = route("DELETE", "/galleries/{GalleryID}/stacks/{StackID}")
	TagStack                 = route("POST", "/galleries/{GalleryID}/stacks/{StackID}/tags")
	UntagStack               = route("DELETE", "/galleries/{GalleryID}/stacks/{StackID}/tags/{Tags}")
	SortGallery              = route("PATCH", "/galleries/{GalleryID}/sorting")

	GalleryReadRoutes = [...]Route{
		LookupGalleryByName,
		LookupGalleryStackByName,
		ShowGallery,
	}

	GalleryWriteRoutes = [...]Route{
		UploadImage,
		ReplaceImage,
		UpdateStack,
		DeleteStack,
		TagStack,
		UntagStack,
		SortGallery,
	}

	GalleryRoutes = [...]Route{
		LookupGalleryByName,
		LookupGalleryStackByName,
		ShowGallery,
		UploadImage,
		ReplaceImage,
		UpdateStack,
		DeleteStack,
		TagStack,
		UntagStack,
	}
)

Gallery routes

View Source
var (
	LookupShelfByName = route("GET", "/shelfs/lookup/name/{Name}")
	ShowShelf         = route("GET", "/shelfs/{ShelfID}")
	UploadDocument    = route("POST", "/shelfs/{ShelfID}/documents")
	ReplaceDocument   = route("PUT", "/shelfs/{ShelfID}/documents/{DocumentID}")
	UpdateDocument    = route("PATCH", "/shelfs/{ShelfID}/documents/{DocumentID}")
	DeleteDocument    = route("DELETE", "/shelfs/{ShelfID}/documents/{DocumentID}")
	TagDocument       = route("POST", "/shelfs/{ShelfID}/documents/{DocumentID}/tags")
	UntagDocument     = route("DELETE", "/shelfs/{ShelfID}/documents/{DocumentID}/tags/{Tags}")

	DocumentReadRoutes = [...]Route{
		LookupShelfByName,
		ShowShelf,
	}

	DocumentWriteRoutes = [...]Route{
		UploadDocument,
		ReplaceDocument,
		UpdateDocument,
		DeleteDocument,
		TagDocument,
		UntagDocument,
	}

	DocumentRoutes = [...]Route{
		LookupShelfByName,
		ShowShelf,
		UploadDocument,
		ReplaceDocument,
		UpdateDocument,
		DeleteDocument,
		TagDocument,
		UntagDocument,
	}
)

Document routes

View Source
var All = route("*", "*")

All is a wildcard for all routes.

Functions

This section is empty.

Types

type Option

type Option func(*Routes)

Option is a Routes option.

func Disable

func Disable(routes ...Route) Option

Disable disables the provided routes.

func Middleware

func Middleware(middleware func(http.Handler) http.Handler, routes ...Route) Option

Middleware adds middleware to the given routes. If routes is empty, the middleware is added to all routes.

func Middlewares

func Middlewares(middlewares []func(http.Handler) http.Handler, routes ...Route) Option

Middlewares adds multiple middlewares to the given routes. If routes is empty, the middleware is added to all routes.

type Route

type Route struct {
	Method string
	Path   string
}

Route is a route with a method and path.

type Routes

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

Routes configures the routes for one of the media components.

func New

func New(opts ...Option) Routes

New returns a route configuration.

func (Routes) Disabled

func (r Routes) Disabled(route Route) bool

Disabled returns whether the given Route is disabled.

func (Routes) Install

func (r Routes) Install(router chi.Router, route Route, h http.Handler)

Install installs the routes in the given Router, using the provided Handler, but only if the Route wasn't disabled.

func (Routes) Middleware

func (r Routes) Middleware(route Route) []func(http.Handler) http.Handler

Middleware returns the middleare for the given Route.

Jump to

Keyboard shortcuts

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