rbmux

package module
v0.0.0-...-dbdc49b Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 6 Imported by: 0

README

Backlog

  • MUST choose a different name for 'r' since it collides with the 'r' of request in handlers
  • COULD create decoder that binds url parameters to be "decoded" from requests
  • COULD maybe also decoder for links links, but that requires parameters.
  • MUST log error for routes not being found in request scope

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Helper = fx.Annotated{
	Target: NewHelper,
	Group:  "rb.helper",
}

Helper annotates all mux helpers as helper

Functions

func NewHelper

func NewHelper(m M) template.FuncMap

NewHelper creates a helper

Types

type M

type M interface {
	CurrentRoute(req *http.Request) string
	URLParam(r *http.Request, k string) string
	URL(name string, pairs ...string) *url.URL
}

M is an interface for reading mux information

func New

func New(logs *zap.Logger, mr *mux.Router) M

New creates a router instance

type Mux

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

Mux implements the m interface

func (*Mux) CurrentRoute

func (m *Mux) CurrentRoute(req *http.Request) (name string)

CurrentRoute returns the name of the current route

func (*Mux) URL

func (m *Mux) URL(name string, pairs ...string) *url.URL

URL generates a url from the route with name 'name' and each parameter provides as key, value in 'pairs'

func (*Mux) URLParam

func (m *Mux) URLParam(req *http.Request, name string) string

Param returns the url parameter value with name 'name', or an empty string

Jump to

Keyboard shortcuts

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