httphandler

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const TIMEOUT time.Duration = time.Second * 4

TIMEOUT is used to control the max duration of an external call

Variables

This section is empty.

Functions

func BillingDay

func BillingDay(url string, matched string, modifier string, when *time.Time) (newUrl string)

BillingDay replaces {billingDay} | {billingDay:<modifier>} patterns with a real value

Implements replaceFunc

func BillingMonth

func BillingMonth(url string, matched string, modifier string, when *time.Time) (newUrl string)

BillingMonth replaces {billingMonth} | {billingMonth:<modifier>} patterns with a real value

Implements replaceFunc

func Day

func Day(url string, matched string, modifier string, when *time.Time) (newUrl string)

Day replaces {day} | {day:<modifier>} patterns with a real value

Implements replaceFunc

func FuncNameAndModifier

func FuncNameAndModifier(match string) (funcName string, modifier string)

FuncNameAndModifier takes a matched string ({<func>:<modifier>}) and returns the values for <func> and <modifier>

func GetAll

func GetAll(scheme string, addr string, paths map[string]string) (responses map[string]*HttpHandler, err error)

GetAll fetches multiple api responses at once tracking them in the map keys passed along

the map is from config.nav datasources

func Month

func Month(url string, matched string, modifier string, when *time.Time) (newUrl string)

Month replaces {month} | {month:<modifier>} patterns with a real value

Implements replaceFunc

func Path

func Path(url string) (parsed string)

Path takes the original string and converts it to a parsed version with the known {<func>:<modifier>} replaced with real versions

Uses a regex to find all patterns that match `{.*}`, parses each of those looking for a matching function name from functionMap and calls the replacer function to swap with real values

Types

type HttpGet

type HttpGet struct {
	Url      *url.URL
	Response *http.Response
	Duration float64
}

func (*HttpGet) Get

func (h *HttpGet) Get() (err error)

Get calls the remote data source in the url and sets the response

type HttpHandler

type HttpHandler struct {
	DataSource *HttpGet
	Response   *http.Response
	StatusCode int
	Duration   float64
	Url        *url.URL
}

func Get

func Get(scheme string, addr string, path string) (response *HttpHandler, err error)

Get combines creating a new instance of HttpHandler and then also calls .Get() method to retrive the data directly

func New

func New(scheme string, addr string, path string) *HttpHandler

New creates a pre configures HttpHandler

func (*HttpHandler) Get

func (a *HttpHandler) Get() (err error)

Get calls remotedata source methof to fetch it and

Jump to

Keyboard shortcuts

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