feat: update pkg name
This commit is contained in:
@@ -3,8 +3,8 @@ package publishers
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"{{.ModuleName}}/app/events"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
)
|
||||
|
||||
var _ contracts.EventPublisher = (*UserRegister)(nil)
|
||||
|
||||
@@ -3,9 +3,9 @@ package subscribers
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"{{.ModuleName}}/app/events"
|
||||
"{{.ModuleName}}/app/events/publishers"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/riverqueue/river"
|
||||
"github.com/sirupsen/logrus"
|
||||
_ "{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
_ "go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
)
|
||||
|
||||
var _ contracts.CronJob = (*CronJob)(nil)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
. "github.com/riverqueue/river"
|
||||
log "github.com/sirupsen/logrus"
|
||||
_ "{{.ModuleName}}/pkg/atom"
|
||||
_ "{{.ModuleName}}/pkg/atom/contracts"
|
||||
_ "go.ipao.vip/atom"
|
||||
_ "go.ipao.vip/atom/contracts"
|
||||
)
|
||||
|
||||
// provider:[except|only] [returnType] [group]
|
||||
|
||||
@@ -3,11 +3,11 @@ package event
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"{{.ModuleName}}/app/events/subscribers"
|
||||
"{{.ModuleName}}/app/service"
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
"{{.ModuleName}}/providers/app"
|
||||
"{{.ModuleName}}/providers/event"
|
||||
"{{.ModuleName}}/providers/postgres"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"{{.ModuleName}}/app/grpc/users"
|
||||
"{{.ModuleName}}/app/service"
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
"{{.ModuleName}}/providers/app"
|
||||
"{{.ModuleName}}/providers/grpc"
|
||||
"{{.ModuleName}}/providers/postgres"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"{{.ModuleName}}/app/errorx"
|
||||
"{{.ModuleName}}/app/jobs"
|
||||
"{{.ModuleName}}/app/service"
|
||||
_ "{{.ModuleName}}/docs"
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
"{{.ModuleName}}/providers/app"
|
||||
"{{.ModuleName}}/providers/hashids"
|
||||
"{{.ModuleName}}/providers/http"
|
||||
|
||||
@@ -3,11 +3,11 @@ package queue
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"{{.ModuleName}}/app/jobs"
|
||||
"{{.ModuleName}}/app/service"
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
"{{.ModuleName}}/providers/app"
|
||||
"{{.ModuleName}}/providers/job"
|
||||
"{{.ModuleName}}/providers/postgres"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"go.ipao.vip/atom/container"
|
||||
"{{.ModuleName}}/providers/app"
|
||||
"{{.ModuleName}}/providers/event"
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
|
||||
"github.com/rogeecn/fabfile"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"{{.ModuleName}}/app/service/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"go.ipao.vip/atom"
|
||||
)
|
||||
|
||||
// @title ApiDoc
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
package atom
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/dig"
|
||||
"{{.ModuleName}}/pkg/atom/config"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
)
|
||||
|
||||
var (
|
||||
GroupInitialName = "initials"
|
||||
GroupRoutesName = "routes"
|
||||
GroupGrpcServerServiceName = "grpc_server_services"
|
||||
GroupCommandName = "command_services"
|
||||
GroupQueueName = "queue_handler"
|
||||
GroupCronJobName = "cron_jobs"
|
||||
|
||||
GroupInitial = dig.Group(GroupInitialName)
|
||||
GroupRoutes = dig.Group(GroupRoutesName)
|
||||
GroupGrpcServer = dig.Group(GroupGrpcServerServiceName)
|
||||
GroupCommand = dig.Group(GroupCommandName)
|
||||
GroupQueue = dig.Group(GroupQueueName)
|
||||
GroupCronJob = dig.Group(GroupCronJobName)
|
||||
)
|
||||
|
||||
func Serve(opts ...Option) error {
|
||||
rootCmd := &cobra.Command{Use: "app"}
|
||||
for _, opt := range opts {
|
||||
opt(rootCmd)
|
||||
}
|
||||
|
||||
rootCmd.SilenceErrors = true
|
||||
rootCmd.SilenceUsage = true
|
||||
rootCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
|
||||
cmd.Println(err)
|
||||
cmd.Println(cmd.UsageString())
|
||||
return err
|
||||
})
|
||||
|
||||
rootCmd.PersistentFlags().StringP("config", "c", "config.toml", "config file")
|
||||
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
func LoadProviders(configFile string, providers container.Providers) error {
|
||||
configure, err := config.Load(configFile)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "load config file: %s", configFile)
|
||||
}
|
||||
|
||||
if err := providers.Provide(configure); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Option func(*cobra.Command)
|
||||
|
||||
var (
|
||||
AppName string
|
||||
AppVersion string
|
||||
)
|
||||
|
||||
func Providers(providers container.Providers) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.PreRunE = func(cmd *cobra.Command, args []string) error {
|
||||
return LoadProviders(cmd.Flag("config").Value.String(), providers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Command(opt ...Option) Option {
|
||||
return func(parentCmd *cobra.Command) {
|
||||
cmd := &cobra.Command{}
|
||||
for _, o := range opt {
|
||||
o(cmd)
|
||||
}
|
||||
parentCmd.AddCommand(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
func Arguments(f func(cmd *cobra.Command)) Option {
|
||||
return f
|
||||
}
|
||||
|
||||
func Version(ver string) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.Version = ver
|
||||
AppVersion = ver
|
||||
}
|
||||
}
|
||||
|
||||
func Name(name string) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.Use = name
|
||||
AppName = name
|
||||
}
|
||||
}
|
||||
|
||||
func Short(short string) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.Short = short
|
||||
}
|
||||
}
|
||||
|
||||
func Long(long string) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.Long = long
|
||||
}
|
||||
}
|
||||
|
||||
func Example(example string) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.Example = example
|
||||
}
|
||||
}
|
||||
|
||||
func Run(run func(cmd *cobra.Command, args []string)) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.Run = run
|
||||
}
|
||||
}
|
||||
|
||||
func RunE(run func(cmd *cobra.Command, args []string) error) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.RunE = run
|
||||
}
|
||||
}
|
||||
|
||||
func PostRun(run func(cmd *cobra.Command, args []string)) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.PostRun = run
|
||||
}
|
||||
}
|
||||
|
||||
func PostRunE(run func(cmd *cobra.Command, args []string) error) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.PostRunE = run
|
||||
}
|
||||
}
|
||||
|
||||
func PreRun(run func(cmd *cobra.Command, args []string)) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.PreRun = run
|
||||
}
|
||||
}
|
||||
|
||||
func PreRunE(run func(cmd *cobra.Command, args []string) error) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
cmd.PreRunE = run
|
||||
}
|
||||
}
|
||||
|
||||
func Config(file string) Option {
|
||||
return func(cmd *cobra.Command) {
|
||||
_ = cmd.PersistentFlags().Set("config", file)
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
)
|
||||
|
||||
func Load(file string) (*viper.Viper, error) {
|
||||
v := viper.NewWithOptions(viper.KeyDelimiter("_"))
|
||||
v.AutomaticEnv()
|
||||
|
||||
ext := filepath.Ext(file)
|
||||
if ext == "" {
|
||||
v.SetConfigType("toml")
|
||||
v.SetConfigFile(file)
|
||||
} else {
|
||||
v.SetConfigType(ext[1:])
|
||||
v.SetConfigFile(file)
|
||||
}
|
||||
|
||||
v.AddConfigPath(".")
|
||||
|
||||
err := v.ReadInConfig()
|
||||
log.Println("config file:", v.ConfigFileUsed())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "config file read error")
|
||||
}
|
||||
|
||||
err = container.Container.Provide(func() (*viper.Viper, error) {
|
||||
return v, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/dig"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
)
|
||||
|
||||
var (
|
||||
Container *dig.Container = dig.New()
|
||||
Cancel context.CancelFunc
|
||||
closeable []func()
|
||||
)
|
||||
|
||||
func init() {
|
||||
closeable = make([]func(), 0)
|
||||
if err := Container.Provide(func() context.Context {
|
||||
signals := []os.Signal{syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL}
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), signals...)
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
Close()
|
||||
cancel()
|
||||
}()
|
||||
Cancel = cancel
|
||||
return ctx
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func AddCloseAble(c func()) {
|
||||
closeable = append(closeable, c)
|
||||
}
|
||||
|
||||
func Close() {
|
||||
for _, c := range closeable {
|
||||
c()
|
||||
}
|
||||
}
|
||||
|
||||
type ProviderContainer struct {
|
||||
Provider func(...opt.Option) error
|
||||
Options []opt.Option
|
||||
}
|
||||
|
||||
type Providers []ProviderContainer
|
||||
|
||||
func (p Providers) With(pcs ...func(...opt.Option) error) Providers {
|
||||
for _, pc := range pcs {
|
||||
p = append(p, ProviderContainer{Provider: pc})
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p Providers) WithProviders(pcs ...Providers) Providers {
|
||||
for _, pc := range pcs {
|
||||
p = append(p, pc...)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p Providers) Provide(config *viper.Viper) error {
|
||||
for _, provider := range p {
|
||||
provider.Options = append(provider.Options, opt.Config(config))
|
||||
if err := provider.Provider(provider.Options...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/riverqueue/river"
|
||||
)
|
||||
|
||||
type CronJob interface {
|
||||
Description() string
|
||||
Periodic() time.Duration
|
||||
JobArgs() []river.JobArgs
|
||||
InsertOpts() *river.InsertOpts
|
||||
RunOnStart() bool
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package contracts
|
||||
|
||||
import "github.com/ThreeDotsLabs/watermill/message"
|
||||
|
||||
type EventHandler interface {
|
||||
Topic() string
|
||||
PublishToTopic() string
|
||||
Handler(msg *message.Message) ([]*message.Message, error)
|
||||
}
|
||||
|
||||
type EventPublisher interface {
|
||||
Topic() string
|
||||
Marshal() ([]byte, error)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type HttpRoute interface {
|
||||
Register(fiber.Router)
|
||||
Name() string
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package contracts
|
||||
|
||||
type Initial interface{}
|
||||
@@ -1,62 +0,0 @@
|
||||
package opt
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Config *viper.Viper
|
||||
Prefix string
|
||||
Name string
|
||||
Group string
|
||||
}
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
func New(opts ...Option) *Options {
|
||||
o := &Options{}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Options) UnmarshalConfig(config interface{}) error {
|
||||
return o.Config.UnmarshalKey(o.Prefix, &config)
|
||||
}
|
||||
|
||||
func (o *Options) DiOptions() []dig.ProvideOption {
|
||||
options := []dig.ProvideOption{}
|
||||
if o.Name != "" {
|
||||
options = append(options, dig.Name(o.Name))
|
||||
}
|
||||
if o.Group != "" {
|
||||
options = append(options, dig.Group(o.Group))
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
func Config(config *viper.Viper) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = config
|
||||
}
|
||||
}
|
||||
|
||||
func Name(name string) Option {
|
||||
return func(o *Options) {
|
||||
o.Name = name
|
||||
}
|
||||
}
|
||||
|
||||
func Group(group string) Option {
|
||||
return func(o *Options) {
|
||||
o.Group = group
|
||||
}
|
||||
}
|
||||
|
||||
func Prefix(prefix string) Option {
|
||||
return func(o *Options) {
|
||||
o.Prefix = prefix
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package f
|
||||
|
||||
import (
|
||||
"mime/multipart"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func File[T any](key string) func(fiber.Ctx) (*multipart.FileHeader, error) {
|
||||
return func(ctx fiber.Ctx) (*multipart.FileHeader, error) {
|
||||
_ = new(T)
|
||||
return ctx.FormFile(key)
|
||||
}
|
||||
}
|
||||
|
||||
func Local[T any](key string) func(fiber.Ctx) (T, error) {
|
||||
return func(ctx fiber.Ctx) (T, error) {
|
||||
v := fiber.Locals[T](ctx, key)
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
||||
func Path[T fiber.GenericType](key string) func(fiber.Ctx) (T, error) {
|
||||
return func(ctx fiber.Ctx) (T, error) {
|
||||
v := fiber.Params[T](ctx, key)
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
||||
func PathParam[T fiber.GenericType](name string) func(fiber.Ctx) (T, error) {
|
||||
return func(ctx fiber.Ctx) (T, error) {
|
||||
v := fiber.Params[T](ctx, name)
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
||||
func Body[T any](name string) func(fiber.Ctx) (*T, error) {
|
||||
return func(ctx fiber.Ctx) (*T, error) {
|
||||
p := new(T)
|
||||
if err := ctx.Bind().Body(p); err != nil {
|
||||
return nil, errors.Wrapf(err, "body: %s", name)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
||||
func QueryParam[T fiber.GenericType](key string) func(fiber.Ctx) (T, error) {
|
||||
return func(ctx fiber.Ctx) (T, error) {
|
||||
v := fiber.Query[T](ctx, key)
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
||||
func Query[T any](name string) func(fiber.Ctx) (*T, error) {
|
||||
return func(ctx fiber.Ctx) (*T, error) {
|
||||
p := new(T)
|
||||
if err := ctx.Bind().Query(p); err != nil {
|
||||
return nil, errors.Wrapf(err, "query: %s", name)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
||||
func Header[T any](name string) func(fiber.Ctx) (*T, error) {
|
||||
return func(ctx fiber.Ctx) (*T, error) {
|
||||
p := new(T)
|
||||
err := ctx.Bind().Header(p)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "header: %s", name)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
||||
func Cookie[T any](name string) func(fiber.Ctx) (*T, error) {
|
||||
return func(ctx fiber.Ctx) (*T, error) {
|
||||
p := new(T)
|
||||
if err := ctx.Bind().Cookie(p); err != nil {
|
||||
return nil, errors.Wrapf(err, "cookie: %s", name)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
||||
func CookieParam(name string) func(fiber.Ctx) (string, error) {
|
||||
return func(ctx fiber.Ctx) (string, error) {
|
||||
return ctx.Cookies(name), nil
|
||||
}
|
||||
}
|
||||
@@ -1,374 +0,0 @@
|
||||
package f
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
var Func0 = Func
|
||||
|
||||
func Func(f fiber.Handler) fiber.Handler {
|
||||
return f
|
||||
}
|
||||
|
||||
func Func1[P1 any](
|
||||
f func(fiber.Ctx, P1) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return f(ctx, p)
|
||||
}
|
||||
}
|
||||
|
||||
func Func2[P1, P2 any](
|
||||
f func(fiber.Ctx, P1, P2) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return f(ctx, p1, p2)
|
||||
}
|
||||
}
|
||||
|
||||
func Func3[P1, P2, P3 any](
|
||||
f func(fiber.Ctx, P1, P2, P3) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3)
|
||||
}
|
||||
}
|
||||
|
||||
func Func4[P1, P2, P3, P4 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return f(ctx, p1, p2, p3, p4)
|
||||
}
|
||||
}
|
||||
|
||||
func Func5[P1, P2, P3, P4, P5 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3, p4, p5)
|
||||
}
|
||||
}
|
||||
|
||||
func Func6[P1, P2, P3, P4, P5, P6 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3, p4, p5, p6)
|
||||
}
|
||||
}
|
||||
|
||||
func Func7[P1, P2, P3, P4, P5, P6, P7 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3, p4, p5, p6, p7)
|
||||
}
|
||||
}
|
||||
|
||||
func Func8[P1, P2, P3, P4, P5, P6, P7, P8 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7, P8) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
pf8 func(fiber.Ctx) (P8, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p8, err := pf8(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3, p4, p5, p6, p7, p8)
|
||||
}
|
||||
}
|
||||
|
||||
func Func9[P1, P2, P3, P4, P5, P6, P7, P8, P9 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7, P8, P9) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
pf8 func(fiber.Ctx) (P8, error),
|
||||
pf9 func(fiber.Ctx) (P9, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p8, err := pf8(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p9, err := pf9(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3, p4, p5, p6, p7, p8, p9)
|
||||
}
|
||||
}
|
||||
|
||||
func Func10[P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) error,
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
pf8 func(fiber.Ctx) (P8, error),
|
||||
pf9 func(fiber.Ctx) (P9, error),
|
||||
pf10 func(fiber.Ctx) (P10, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p8, err := pf8(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p9, err := pf9(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p10, err := pf10(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f(ctx, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
|
||||
}
|
||||
}
|
||||
@@ -1,413 +0,0 @@
|
||||
package f
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func DataFunc0[T any](
|
||||
f func(fiber.Ctx) (T, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
data, err := f(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc1[T any, P1 any](
|
||||
f func(fiber.Ctx, P1) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := f(ctx, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc2[T any, P1 any, P2 any](
|
||||
f func(fiber.Ctx, P1, P2) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc3[T any, P1 any, P2 any, P3 any](
|
||||
f func(fiber.Ctx, P1, P2, P3) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc4[T any, P1 any, P2 any, P3 any, P4 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc5[T any, P1 any, P2 any, P3 any, P4 any, P5 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4, p5)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc6[T any, P1 any, P2 any, P3 any, P4 any, P5 any, P6 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4, p5, p6)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc7[T any, P1 any, P2 any, P3 any, P4 any, P5 any, P6 any, P7 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4, p5, p6, p7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc8[T any, P1 any, P2 any, P3 any, P4 any, P5 any, P6 any, P7 any, P8 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7, P8) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
pf8 func(fiber.Ctx) (P8, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p8, err := pf8(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4, p5, p6, p7, p8)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc9[T any, P1 any, P2 any, P3 any, P4 any, P5 any, P6 any, P7 any, P8 any, P9 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7, P8, P9) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
pf8 func(fiber.Ctx) (P8, error),
|
||||
pf9 func(fiber.Ctx) (P9, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p8, err := pf8(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p9, err := pf9(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4, p5, p6, p7, p8, p9)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
|
||||
func DataFunc10[T any, P1 any, P2 any, P3 any, P4 any, P5 any, P6 any, P7 any, P8 any, P9 any, P10 any](
|
||||
f func(fiber.Ctx, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) (T, error),
|
||||
pf1 func(fiber.Ctx) (P1, error),
|
||||
pf2 func(fiber.Ctx) (P2, error),
|
||||
pf3 func(fiber.Ctx) (P3, error),
|
||||
pf4 func(fiber.Ctx) (P4, error),
|
||||
pf5 func(fiber.Ctx) (P5, error),
|
||||
pf6 func(fiber.Ctx) (P6, error),
|
||||
pf7 func(fiber.Ctx) (P7, error),
|
||||
pf8 func(fiber.Ctx) (P8, error),
|
||||
pf9 func(fiber.Ctx) (P9, error),
|
||||
pf10 func(fiber.Ctx) (P10, error),
|
||||
) fiber.Handler {
|
||||
return func(ctx fiber.Ctx) error {
|
||||
p1, err := pf1(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p2, err := pf2(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p3, err := pf3(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p4, err := pf4(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p5, err := pf5(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p6, err := pf6(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p7, err := pf7(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p8, err := pf8(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p9, err := pf9(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p10, err := pf10(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := f(ctx, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.JSON(data)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "App"
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"{{.ModuleName}}/providers/http"
|
||||
|
||||
"github.com/soheilhy/cmux"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "Cmux"
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"{{.ModuleName}}/providers/http"
|
||||
|
||||
"github.com/soheilhy/cmux"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "Events"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"github.com/ThreeDotsLabs/watermill/pubsub/gochannel"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill-kafka/v3/pkg/kafka"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill-redisstream/pkg/redisstream"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
|
||||
@@ -3,8 +3,8 @@ package event
|
||||
import (
|
||||
sqlDB "database/sql"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill-sql/v3/pkg/sql"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package hashids
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "HashIDs"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package hashids
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/speps/go-hashids/v2"
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/gofiber/fiber/v3/middleware/logger"
|
||||
|
||||
@@ -2,8 +2,8 @@ package job
|
||||
|
||||
import (
|
||||
"github.com/riverqueue/river"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "Job"
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/riverqueue/river"
|
||||
"github.com/riverqueue/river/riverdriver/riverpgxv5"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "JWT"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v4"
|
||||
"golang.org/x/sync/singleflight"
|
||||
|
||||
@@ -3,9 +3,9 @@ package otel
|
||||
import (
|
||||
"os"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "OTEL"
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/contracts"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.ipao.vip/atom/opt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
@@ -3,8 +3,8 @@ package postgres
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "Database"
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
|
||||
@@ -3,8 +3,8 @@ package redis
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "Redis"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"{{.ModuleName}}/providers/req/cookiejar"
|
||||
|
||||
"github.com/imroc/req/v3"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package req
|
||||
|
||||
import (
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "HttpClient"
|
||||
|
||||
@@ -2,8 +2,8 @@ package tracing
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
const DefaultPrefix = "Tracing"
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
config "github.com/uber/jaeger-client-go/config"
|
||||
"{{.ModuleName}}/pkg/atom/container"
|
||||
"{{.ModuleName}}/pkg/atom/opt"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
|
||||
Reference in New Issue
Block a user