api

package
v0.0.0-...-23bfcb2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package api holds types, functions, methods for dispatching http requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

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

Api type defines what dependencies we need in order to fulfill http requests.

func New

func New(fib Fibonacci) *Api

New returns a new Api instance that hoists all necessary dependencies to offer http server methods.

func (*Api) Current

func (a *Api) Current(w http.ResponseWriter, r *http.Request)

Current returns the current fibonacci sequence for the http client.

func (*Api) Handler

func (a *Api) Handler() http.Handler

Handler returns a http.Handler ready for multiplexing requests to different endpoints.

func (*Api) Next

func (a *Api) Next(w http.ResponseWriter, r *http.Request)

Next returns the next fibonacci sequence for the http client.

func (*Api) Previous

func (a *Api) Previous(w http.ResponseWriter, r *http.Request)

Previous returns the previous fibonacci sequence for the http client.

type Fibonacci

type Fibonacci interface {
	// Next takes a unique identifier to identify a caller and
	// returns the next fibonacci sequence number.
	Next(id string) string
	// Previous takes a unique identifier to identify a caller and
	// returns the previous fibonacci sequence number.
	Previous(id string) string
	// Current takes a unique identifier to identify a caller and
	// returns the current fibonacci sequence number.
	Current(id string) string
}

Fibonacci defines how we generate fibonacci numbers for unique clients.

Jump to

Keyboard shortcuts

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