workspace

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workspace resolves which workspace a request belongs to.

Every piece of data in Workly is scoped to a workspace, but the workspace never appears in API paths: it is derived from the request's credentials. That keeps client code identical across `workly dev`, self-hosted and hosted deployments.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("unauthorized")

ErrUnauthorized is returned by a Resolver when the request carries missing or invalid credentials.

Functions

func BearerToken

func BearerToken(r *http.Request) (string, bool)

BearerToken extracts the token from an `Authorization: Bearer <token>` header.

func WithID

func WithID(ctx context.Context, id ID) context.Context

WithID returns a context carrying the resolved workspace.

Types

type ID

type ID string

ID identifies a workspace.

const Default ID = "default"

Default is the single workspace used by `workly dev` and self-hosted servers.

func FromContext

func FromContext(ctx context.Context) (ID, bool)

FromContext returns the workspace resolved for the current request.

type Resolver

type Resolver interface {
	Resolve(r *http.Request) (ID, error)
}

Resolver maps an incoming request to a workspace.

type Static

type Static struct {
	ID     ID
	APIKey string
}

Static resolves every request to one workspace. If APIKey is non-empty, requests must present it as a bearer token.

func (Static) Resolve

func (s Static) Resolve(r *http.Request) (ID, error)

Jump to

Keyboard shortcuts

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