76 lines
1.9 KiB
Go
Raw Permalink Normal View History

2022-03-07 20:49:02 +08:00
// Code generated by goa v3.6.0, DO NOT EDIT.
//
// Service1 endpoints
//
// Command:
// $ goa gen goa_example/design
package service1
import (
"context"
goa "goa.design/goa/v3/pkg"
"goa.design/goa/v3/security"
)
// Endpoints wraps the "Service1" service endpoints.
type Endpoints struct {
Signin goa.Endpoint
Secure goa.Endpoint
}
// NewEndpoints wraps the methods of the "Service1" service with endpoints.
func NewEndpoints(s Service) *Endpoints {
// Casting service to Auther interface
a := s.(Auther)
return &Endpoints{
Signin: NewSigninEndpoint(s, a.BasicAuth),
Secure: NewSecureEndpoint(s, a.JWTAuth),
}
}
// Use applies the given middleware to all the "Service1" service endpoints.
func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) {
e.Signin = m(e.Signin)
e.Secure = m(e.Secure)
}
// NewSigninEndpoint returns an endpoint function that calls the method
// "signin" of service "Service1".
func NewSigninEndpoint(s Service, authBasicFn security.AuthBasicFunc) goa.Endpoint {
return func(ctx context.Context, req interface{}) (interface{}, error) {
p := req.(*SigninPayload)
var err error
sc := security.BasicScheme{
Name: "basic",
Scopes: []string{},
RequiredScopes: []string{},
}
ctx, err = authBasicFn(ctx, p.Username, p.Password, &sc)
if err != nil {
return nil, err
}
return s.Signin(ctx, p)
}
}
// NewSecureEndpoint returns an endpoint function that calls the method
// "secure" of service "Service1".
func NewSecureEndpoint(s Service, authJWTFn security.AuthJWTFunc) goa.Endpoint {
return func(ctx context.Context, req interface{}) (interface{}, error) {
p := req.(*SecurePayload)
var err error
sc := security.JWTScheme{
Name: "jwt",
Scopes: []string{},
RequiredScopes: []string{},
}
ctx, err = authJWTFn(ctx, p.Token, &sc)
if err != nil {
return nil, err
}
return s.Secure(ctx, p)
}
}