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 ¶
- func Build() fx.Option
- type Accounts
- type Authentication
- func (o *Authentication) AuthOAuthProviderCallback(ctx context.Context, request openapi.AuthOAuthProviderCallbackRequestObject) (openapi.AuthOAuthProviderCallbackResponseObject, error)
- func (o *Authentication) AuthOAuthProviderList(ctx context.Context, request openapi.AuthOAuthProviderListRequestObject) (openapi.AuthOAuthProviderListResponseObject, error)
- func (i *Authentication) AuthPasswordSignin(ctx context.Context, request openapi.AuthPasswordSigninRequestObject) (openapi.AuthPasswordSigninResponseObject, error)
- func (i *Authentication) AuthPasswordSignup(ctx context.Context, request openapi.AuthPasswordSignupRequestObject) (openapi.AuthPasswordSignupResponseObject, error)
- type Bindings
- type Posts
- type Profiles
- type Spec
- type Threads
- func (i *Threads) ThreadsCreate(ctx context.Context, request openapi.ThreadsCreateRequestObject) (openapi.ThreadsCreateResponseObject, error)
- func (i *Threads) ThreadsGet(ctx context.Context, request openapi.ThreadsGetRequestObject) (openapi.ThreadsGetResponseObject, error)
- func (i *Threads) ThreadsList(ctx context.Context, request openapi.ThreadsListRequestObject) (openapi.ThreadsListResponseObject, error)
- type Version
- type WebAuthn
- func (a *WebAuthn) WebAuthnGetAssertion(ctx context.Context, request openapi.WebAuthnGetAssertionRequestObject) (openapi.WebAuthnGetAssertionResponseObject, error)
- func (a *WebAuthn) WebAuthnMakeAssertion(ctx context.Context, request openapi.WebAuthnMakeAssertionRequestObject) (openapi.WebAuthnMakeAssertionResponseObject, error)
- func (a *WebAuthn) WebAuthnMakeCredential(ctx context.Context, request openapi.WebAuthnMakeCredentialRequestObject) (openapi.WebAuthnMakeCredentialResponseObject, error)
- func (a *WebAuthn) WebAuthnRequestCredential(ctx context.Context, request openapi.WebAuthnRequestCredentialRequestObject) (openapi.WebAuthnRequestCredentialResponseObject, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
func NewAccounts ¶
func (*Accounts) AccountsGet ¶
func (i *Accounts) AccountsGet(ctx context.Context, request openapi.AccountsGetRequestObject) (openapi.AccountsGetResponseObject, error)
type Authentication ¶
type Authentication struct {
// contains filtered or unexported fields
}
func NewAuthentication ¶
func NewAuthentication( cfg config.Config, p *password.Password, ar account.Repository, sc *securecookie.SecureCookie, oa *oauth.OAuth, wa *webauthn.WebAuthn, ) Authentication
func (*Authentication) AuthOAuthProviderCallback ¶
func (o *Authentication) AuthOAuthProviderCallback(ctx context.Context, request openapi.AuthOAuthProviderCallbackRequestObject) (openapi.AuthOAuthProviderCallbackResponseObject, error)
func (*Authentication) AuthOAuthProviderList ¶
func (o *Authentication) AuthOAuthProviderList(ctx context.Context, request openapi.AuthOAuthProviderListRequestObject) (openapi.AuthOAuthProviderListResponseObject, error)
func (*Authentication) AuthPasswordSignin ¶
func (i *Authentication) AuthPasswordSignin(ctx context.Context, request openapi.AuthPasswordSigninRequestObject) (openapi.AuthPasswordSigninResponseObject, error)
func (*Authentication) AuthPasswordSignup ¶
func (i *Authentication) AuthPasswordSignup(ctx context.Context, request openapi.AuthPasswordSignupRequestObject) (openapi.AuthPasswordSignupResponseObject, error)
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
func (*Posts) PostsCreate ¶
func (p *Posts) PostsCreate(ctx context.Context, request openapi.PostsCreateRequestObject) (openapi.PostsCreateResponseObject, error)
type Profiles ¶
type Profiles struct {
// contains filtered or unexported fields
}
func NewProfiles ¶
func (*Profiles) ProfilesGet ¶
func (p *Profiles) ProfilesGet(ctx context.Context, request openapi.ProfilesGetRequestObject) (openapi.ProfilesGetResponseObject, error)
type Spec ¶
type Spec struct{}
func (*Spec) GetSpec ¶
func (v *Spec) GetSpec(ctx context.Context, request openapi.GetSpecRequestObject) (openapi.GetSpecResponseObject, error)
type Threads ¶
type Threads struct {
// contains filtered or unexported fields
}
func NewThreads ¶
func NewThreads(thread_svc thread_service.Service) Threads
func (*Threads) ThreadsCreate ¶
func (i *Threads) ThreadsCreate(ctx context.Context, request openapi.ThreadsCreateRequestObject) (openapi.ThreadsCreateResponseObject, error)
func (*Threads) ThreadsGet ¶
func (i *Threads) ThreadsGet(ctx context.Context, request openapi.ThreadsGetRequestObject) (openapi.ThreadsGetResponseObject, error)
func (*Threads) ThreadsList ¶
func (i *Threads) ThreadsList(ctx context.Context, request openapi.ThreadsListRequestObject) (openapi.ThreadsListResponseObject, error)
type Version ¶
type Version struct{}
func NewVersion ¶
func NewVersion() Version
func (*Version) GetVersion ¶
func (v *Version) GetVersion(ctx context.Context, request openapi.GetVersionRequestObject) (openapi.GetVersionResponseObject, error)
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
func (*WebAuthn) WebAuthnGetAssertion ¶
func (a *WebAuthn) WebAuthnGetAssertion(ctx context.Context, request openapi.WebAuthnGetAssertionRequestObject) (openapi.WebAuthnGetAssertionResponseObject, error)
func (*WebAuthn) WebAuthnMakeAssertion ¶
func (a *WebAuthn) WebAuthnMakeAssertion(ctx context.Context, request openapi.WebAuthnMakeAssertionRequestObject) (openapi.WebAuthnMakeAssertionResponseObject, error)
func (*WebAuthn) WebAuthnMakeCredential ¶
func (a *WebAuthn) WebAuthnMakeCredential(ctx context.Context, request openapi.WebAuthnMakeCredentialRequestObject) (openapi.WebAuthnMakeCredentialResponseObject, error)
func (*WebAuthn) WebAuthnRequestCredential ¶
func (a *WebAuthn) WebAuthnRequestCredential(ctx context.Context, request openapi.WebAuthnRequestCredentialRequestObject) (openapi.WebAuthnRequestCredentialResponseObject, error)