bindings

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package bindings is responsible for providing a bridge between the code that is generated from the OpenAPI specification that comprises the "Transport" layer and the code that implements the product, or the "Service" layer.

This package is structured as a set of structs which are compose together in the struct called `Bindings` which implements an interface generated by the oapi-codegen tool which describes all the endpoints.

Aside from `bindings.go`, pretty much every Go file is named after a REST collection from the OpenAPI specification.

## Adding Routes

To add a new route, you first modify the OpenAPI specification YAML document and then run the `generate` task which generates all the handler declarations and types necessary to implement the binding.

Next, you create a file in this package named after the collection. So if you added `/v1/things` you'd create `things.go` and inside that file, a struct named `Things` and a constructor named `NewThings`. This pattern may not always apply for certain cases but it's generally best to try to follow.

You then add your struct to the `Bindings` composed struct and provide the implementation of your struct to the DI system using `bindingsProviders`.

## Changing Routes

Updating a route is as simple as just modifying the OpenAPI specification and making the necessary changes to the bindings to get the code compiling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build() fx.Option

Types

type Accounts

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

func NewAccounts

func NewAccounts(as account.Service) Accounts

type Authentication

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

type Bindings

Bindings is a DI parameter struct that is used to compose together all of the individual service bindings in this package. When the provider below depends on this type, it provides all these composed bindings to the DI system so the invoke call can mount them onto the router using the `StrictServerInterface`.

The reason this is done this way is so we split code up based on OpenAPI REST collections instead of bundling everything into one huge struct with loads of dependencies. This is just how the oapi-codegen tool works, by generating one big interface which the bindings layer must satisfy.

type Posts

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

func NewPosts

func NewPosts(post_svc post_service.Service) Posts

type Profiles

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

func NewProfiles

func NewProfiles(as account.Service) Profiles

type Spec

type Spec struct{}

func NewSpec

func NewSpec() Spec

func (*Spec) GetSpec

type Threads

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

func NewThreads

func NewThreads(thread_svc thread_service.Service) Threads

type Version

type Version struct{}

func NewVersion

func NewVersion() Version

type WebAuthn

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

func NewWebAuthn

func NewWebAuthn(
	cfg config.Config,
	ar account.Repository,
	sc *securecookie.SecureCookie,
	wa *webauthn.WebAuthn,
	router *echo.Echo,
) WebAuthn

Jump to

Keyboard shortcuts

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