wdresolve

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

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

Go to latest
Published: Jan 8, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

README

wdresolve

This repository implements the resolver for the WissKI Distillery. Documentation tbd.

Deployment

Publish Docker Image

Available as a Docker Image on GitHub Packages. Automatically built on every commit.

 docker run -ti -p 8080:8080 -e DEFAULT_DOMAIN=wisski.data.fau.de -e LEGACY_DOMAIN=wisski.agfd.fau.de -e PREFIX_FILE=/prefixes -v $(pwd)/cmd/wdresolve/prefixes.example:/prefixes:ro ghcr.io/fau-cdi/wdresolve

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrefixTarget

func PrefixTarget(resolver PrefixResolver, uri string) (url string)

PrefixTarget implemen s Target for PrefixResolvers

Types

type HandlerAction

type HandlerAction int

HandlerAction is an action the handler should perform

const (
	DefaultAction HandlerAction = iota
	IndexAction                 // Show the user an index page
	ResolveAction               // resolve a URI
)

type IndexContext

type IndexContext struct {
	Prefixes [][2]string
	URL      string
}

ResolverHandlerContext is the context for the resolver handler

type PrefixResolver

type PrefixResolver interface {
	Resolver
	Prefixes() map[string]string
}

PrefixResolver is a resolver that resolves WissKI base URIs using a longest prefix match. Resolver should call PrefixTarget()

type ResolveHandler

type ResolveHandler struct {
	Resolver             Resolver
	TrustXForwardedProto bool

	// HandleIndex optionally handles the index page for a given router.
	// When nil, renders the default index template.
	HandleIndex func(context IndexContext, w http.ResponseWriter, r *http.Request)
}

ResolveHandler implements http.Handler and resolves WissKI URIs to individual WissKI Resolve URIs.

func (ResolveHandler) Action

func (ResolveHandler) Action(r *http.Request) (action HandlerAction, uri string)

Action extracts the action and uri to perform the action on When no uri exists, returns the empty string.

func (ResolveHandler) ResolverURL

func (ResolveHandler) ResolverURL(target, uri string) string

func (ResolveHandler) ServeHTTP

func (rh ResolveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServerHTTP implements the http.Handler interface

func (ResolveHandler) ServeIndex

func (rh ResolveHandler) ServeIndex(context IndexContext, w http.ResponseWriter, r *http.Request)

ServeIndex responds to context with the index page

type Resolver

type Resolver interface {
	Target(uri string) string
}

Resolver resolves URIs to WissKI base URIs

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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