Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 1.92 KB

api.rst

File metadata and controls

77 lines (50 loc) · 1.92 KB

API reference

This API reference is intended mainly for developers and people looking for in-depth description of the different classes and functions. If you simply want to configure models and parse values into hyperlinks, quickstart gives a better introduction to using the library.

hrefs

Fundamentals

The two main building blocks of the hrefs library are

  • Href, the class representing hyperlinks
  • Referrable, the abstract base class of types that can be targets of hyperlinks

Href

Referrable

Pydantic models

Any pydantic model that is a target of hyperlinks should implement BaseReferrableModel. It inherits both pydantic.BaseModel and hrefs.Referrable.

BaseReferrableModel

PrimaryKey

HrefsConfigDict

Starlette integration

hrefs.starlette

The main motivation for writing this library was to make it easy to use hyperlinks in FastAPI and Starlette applications. See quickstart for a fully working example of how to use these classes.

HrefMiddleware

href_context

Custom web framework integrations

Developers of custom web framework integrations that work with BaseReferrableModel need to implement a hyperlink resolver that acts as a bridge between the hrefs library and the framework.

The implementation of hrefs.starlette can be used as a reference.

hrefs.model.HrefResolver

hrefs.model.resolve_hrefs

Exceptions

hrefs.ReferrableModelError