Documentation
¶
Index ¶
- Variables
- func Funcs() template.FuncMap
- func PathToChiPattern(path string) string
- func PathToEchoPattern(path string) string
- func PathToFiberPattern(path string) string
- func PathToGinPattern(path string) string
- func PathToGorillaPattern(path string) string
- func PathToIrisPattern(path string) string
- func PathToStdHTTPPattern(path string) string
- func ToGoIdentifier(s string) string
- type ClientTemplate
- type Import
- type InitiatorTemplate
- type ReceiverTemplate
- type SenderTemplate
- type ServerTemplate
Constants ¶
This section is empty.
Variables ¶
var ChiReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, }, Template: "server/chi/receiver.go.tmpl", }, }
ChiReceiverTemplates contains receiver templates for Chi servers.
var ChiServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, }, Template: "server/chi/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "net/http"}, {Path: "github.com/go-chi/chi/v5"}, }, Template: "server/chi/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/go-chi/chi/v5"}, }, Template: "server/chi/wrapper.go.tmpl", }, }
ChiServerTemplates contains templates for Chi server generation.
var ClientTemplates = map[string]ClientTemplate{ "base": { Name: "base", Imports: []Import{ {Path: "context"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "strings"}, }, Template: "client/base.go.tmpl", }, }
ClientTemplates contains the base template for client generation.
var EchoReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/labstack/echo/v5"}, }, Template: "server/echo/receiver.go.tmpl", }, }
EchoReceiverTemplates contains receiver templates for Echo v5 servers.
var EchoServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, {Path: "github.com/labstack/echo/v5"}, }, Template: "server/echo/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "github.com/labstack/echo/v5"}, }, Template: "server/echo/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/labstack/echo/v5"}, }, Template: "server/echo/wrapper.go.tmpl", }, }
EchoServerTemplates contains templates for Echo v5 server generation.
var EchoV4ReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/labstack/echo/v4"}, }, Template: "server/echo-v4/receiver.go.tmpl", }, }
EchoV4ReceiverTemplates contains receiver templates for Echo v4 servers.
var EchoV4ServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, {Path: "github.com/labstack/echo/v4"}, }, Template: "server/echo-v4/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "github.com/labstack/echo/v4"}, }, Template: "server/echo-v4/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/labstack/echo/v4"}, }, Template: "server/echo-v4/wrapper.go.tmpl", }, }
EchoV4ServerTemplates contains templates for Echo v4 server generation.
var FiberReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/gofiber/fiber/v3"}, }, Template: "server/fiber/receiver.go.tmpl", }, }
FiberReceiverTemplates contains receiver templates for Fiber servers.
var FiberServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "github.com/gofiber/fiber/v3"}, }, Template: "server/fiber/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "github.com/gofiber/fiber/v3"}, }, Template: "server/fiber/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/gofiber/fiber/v3"}, }, Template: "server/fiber/wrapper.go.tmpl", }, }
FiberServerTemplates contains templates for Fiber server generation.
var GinReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/gin-gonic/gin"}, }, Template: "server/gin/receiver.go.tmpl", }, }
GinReceiverTemplates contains receiver templates for Gin servers.
var GinServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, {Path: "github.com/gin-gonic/gin"}, }, Template: "server/gin/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "github.com/gin-gonic/gin"}, }, Template: "server/gin/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/gin-gonic/gin"}, }, Template: "server/gin/wrapper.go.tmpl", }, }
GinServerTemplates contains templates for Gin server generation.
var GorillaReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, }, Template: "server/gorilla/receiver.go.tmpl", }, }
GorillaReceiverTemplates contains receiver templates for Gorilla servers.
var GorillaServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, }, Template: "server/gorilla/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "net/http"}, {Path: "github.com/gorilla/mux"}, }, Template: "server/gorilla/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/gorilla/mux"}, }, Template: "server/gorilla/wrapper.go.tmpl", }, }
GorillaServerTemplates contains templates for Gorilla server generation.
var InitiatorTemplates = map[string]InitiatorTemplate{ "initiator_base": { Name: "initiator_base", Imports: []Import{ {Path: "context"}, {Path: "net/http"}, }, Template: "initiator/base.go.tmpl", }, }
InitiatorTemplates contains the base template for initiator generation.
var IrisReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/kataras/iris/v12"}, }, Template: "server/iris/receiver.go.tmpl", }, }
IrisReceiverTemplates contains receiver templates for Iris servers.
var IrisServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, {Path: "github.com/kataras/iris/v12"}, }, Template: "server/iris/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "github.com/kataras/iris/v12"}, }, Template: "server/iris/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "github.com/kataras/iris/v12"}, }, Template: "server/iris/wrapper.go.tmpl", }, }
IrisServerTemplates contains templates for Iris server generation.
var SenderTemplates = map[string]SenderTemplate{ "sender_interface": { Name: "sender_interface", Imports: []Import{ {Path: "context"}, {Path: "io"}, {Path: "net/http"}, }, Template: "sender/interface.go.tmpl", }, "sender_methods": { Name: "sender_methods", Imports: []Import{ {Path: "context"}, {Path: "io"}, {Path: "net/http"}, }, Template: "sender/methods.go.tmpl", }, "sender_request_builders": { Name: "sender_request_builders", Imports: []Import{ {Path: "bytes"}, {Path: "encoding/json"}, {Path: "fmt"}, {Path: "io"}, {Path: "net/http"}, {Path: "net/url"}, {Path: "strings"}, }, Template: "sender/request_builders.go.tmpl", }, "sender_simple": { Name: "sender_simple", Imports: []Import{ {Path: "context"}, {Path: "encoding/json"}, {Path: "fmt"}, {Path: "io"}, {Path: "net/http"}, }, Template: "sender/simple.go.tmpl", }, }
SenderTemplates contains templates shared between client and initiator generators.
"errors": { Name: "errors", Imports: []Import{ {Path: "fmt"}, }, Template: "server/errors.go.tmpl", }, "param_types": { Name: "param_types", Imports: []Import{}, Template: "server/param_types.go.tmpl", }, }
SharedServerTemplates contains templates shared across all server implementations.
var StdHTTPReceiverTemplates = map[string]ReceiverTemplate{ "receiver": { Name: "receiver", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, }, Template: "server/stdhttp/receiver.go.tmpl", }, }
StdHTTPReceiverTemplates contains receiver templates for StdHTTP servers.
var StdHTTPServerTemplates = map[string]ServerTemplate{ "interface": { Name: "interface", Imports: []Import{ {Path: "net/http"}, }, Template: "server/stdhttp/interface.go.tmpl", }, "handler": { Name: "handler", Imports: []Import{ {Path: "net/http"}, }, Template: "server/stdhttp/handler.go.tmpl", }, "wrapper": { Name: "wrapper", Imports: []Import{ {Path: "encoding/json"}, {Path: "fmt"}, {Path: "net/http"}, {Path: "net/url"}, }, Template: "server/stdhttp/wrapper.go.tmpl", }, }
StdHTTPServerTemplates contains templates for StdHTTP server generation.
var TemplateFS embed.FS
TemplateFS contains all embedded template files. The files/* pattern recursively includes all files in subdirectories.
Functions ¶
func PathToChiPattern ¶
PathToChiPattern converts an OpenAPI path template to a Chi-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Chi: /users/{user_id}/posts/{post_id}
func PathToEchoPattern ¶
PathToEchoPattern converts an OpenAPI path template to an Echo-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Echo: /users/:user_id/posts/:post_id
func PathToFiberPattern ¶
PathToFiberPattern converts an OpenAPI path template to a Fiber-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Fiber: /users/:user_id/posts/:post_id
func PathToGinPattern ¶
PathToGinPattern converts an OpenAPI path template to a Gin-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Gin: /users/:user_id/posts/:post_id
func PathToGorillaPattern ¶
PathToGorillaPattern converts an OpenAPI path template to a Gorilla Mux-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Gorilla: /users/{user_id}/posts/{post_id}
func PathToIrisPattern ¶
PathToIrisPattern converts an OpenAPI path template to an Iris-compatible pattern. OpenAPI: /users/{user_id}/posts/{post_id} Iris: /users/:user_id/posts/:post_id
func PathToStdHTTPPattern ¶
PathToStdHTTPPattern converts an OpenAPI path template to a Go 1.22+ std http pattern. OpenAPI: /users/{user_id}/posts/{post_id} StdHTTP: /users/{user_id}/posts/{post_id} Special case: "/" becomes "/{$}" to match only the root path.
func ToGoIdentifier ¶
ToGoIdentifier converts a string to a valid Go identifier. This is a simple version for template usage.
Types ¶
type ClientTemplate ¶
type ClientTemplate struct {
Name string // Template name (e.g., "base")
Imports []Import // Required imports for this template
Template string // Template path in embedded FS
}
ClientTemplate defines a template for client generation.
type InitiatorTemplate ¶
type InitiatorTemplate struct {
Name string // Template name (e.g., "initiator_base")
Imports []Import // Required imports for this template
Template string // Template path in embedded FS
}
InitiatorTemplate defines a template for initiator (webhook/callback sender) generation.
type ReceiverTemplate ¶
type ReceiverTemplate struct {
Name string // Template name (e.g., "receiver")
Imports []Import // Required imports for this template
Template string // Template path in embedded FS
}
ReceiverTemplate defines a template for receiver (webhook/callback) generation.
type SenderTemplate ¶
type SenderTemplate struct {
Name string // Template name (e.g., "sender_interface")
Imports []Import // Required imports for this template
Template string // Template path in embedded FS
}
SenderTemplate defines a template shared between client and initiator generation.
type ServerTemplate ¶
type ServerTemplate struct {
Name string // Template name (e.g., "interface", "handler")
Imports []Import // Required imports for this template
Template string // Template path in embedded FS
}
ServerTemplate defines a template for server generation.