proxy

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

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 7 Imported by: 0

README

jsonapi-reverse-proxy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReverseProxyHandler

type ReverseProxyHandler struct {
	jsonapi.URLResolver              // The URL resolver.
	BaseURL             string       // The base URL of the JSON:API server.
	Client              jsonapi.Doer // The HTTP client.
}

ReverseProxyHandler is a handler that forwards client requests to the JSON:API server at the given base URL.

func NewReverseProxyHandler

func NewReverseProxyHandler(baseURL string, options ...func(*ReverseProxyHandler)) ReverseProxyHandler

NewReverseProxyHandler creates a new reverse proxy handler. This handler forwards client requests to the JSON:API server at the given base URL.

By default, NewReverseProxyHandler generates the following urls (given a base url):

":base/:type" for search, create
":base/:type/:id" for fetch, update, delete
":base/:type/:id/relationships/:ref" for fetchRef
":base/:type/:id/:ref" for fetchRelated

This behavior can be modified by updating the URLResolver field of a ReverseProxyHandler instance.

func (ReverseProxyHandler) ServeJSONAPI

func (p ReverseProxyHandler) ServeJSONAPI(r *http.Request) jsonapi.Response

ServeJSONAPI forwards the request to the JSON:API server at the given base URL.

Jump to

Keyboard shortcuts

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