common

package
v0.0.0-...-86833b7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	URLGenType = reflect.TypeOf((*URLGen)(nil)).Elem()
)

Functions

func GenURL

func GenURL(cdi *container.Registry, resource string, v ...interface{}) string

GenURL generates an URL with the URLGen available in the scope

Types

type BaseURL

type BaseURL func(...interface{}) string

BaseURL holds an base url, invoking this func will return the base url with query string, ex: NewBaseURL("/search")("q", "my search input","page",5) will result in /search?q=my search input&page=5

func GenQS

func GenQS(global *container.Registry, resource string, parameters ...interface{}) BaseURL

GenQS generates a url + query string ex: GenQS(nil,"http://google.com/")("q","cats") => Generates http://google.com/?q=cats

or use with GenQS("app.ProductController.ActionHandler","urlParam")("page",5)

func NewBaseURL

func NewBaseURL(url string) BaseURL

NewBaseURL creates a new BaseURL, see type BaseURL func(...interface{}) string

func (BaseURL) New

func (fn BaseURL) New(urlPath string) BaseURL

New will append urlPath to the current base url ex: NewBaseURL("/api").New("/users") is will return an equivalent BaseURL{"/api/users"}

func (BaseURL) String

func (fn BaseURL) String() string

type URLGen

type URLGen interface {
	URL(resource string, v ...interface{}) string // URL generates an URL
}

URLGen url generator

func GetURLGen

func GetURLGen(cdi *container.Registry) URLGen

Gets an URL generator from the scope

Jump to

Keyboard shortcuts

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