ports

package
v0.0.0-...-e3377f5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ports provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.16.2 DO NOT EDIT.

Index

Constants

View Source
const (
	BearerAuthScopes = "bearerAuth.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type CreateUserJSONRequestBody

type CreateUserJSONRequestBody = User

CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type Error

type Error struct {
	Message string `json:"message"`
	Slug    string `json:"slug"`
}

Error defines model for Error.

type HttpServer

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

func NewHttpServer

func NewHttpServer(repo UserRepository) *HttpServer

func (HttpServer) CreateUser

func (h HttpServer) CreateUser(ctx echo.Context) error

func (HttpServer) GetUserById

func (h HttpServer) GetUserById(ctx echo.Context, userId int) error

func (HttpServer) GetUsers

func (h HttpServer) GetUsers(ctx echo.Context) error

type ServerInterface

type ServerInterface interface {

	// (GET /users)
	GetUsers(ctx echo.Context) error

	// (POST /users)
	CreateUser(ctx echo.Context) error

	// (GET /users/{userId})
	GetUserById(ctx echo.Context, userId int) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CreateUser

func (w *ServerInterfaceWrapper) CreateUser(ctx echo.Context) error

CreateUser converts echo context to params.

func (*ServerInterfaceWrapper) GetUserById

func (w *ServerInterfaceWrapper) GetUserById(ctx echo.Context) error

GetUserById converts echo context to params.

func (*ServerInterfaceWrapper) GetUsers

func (w *ServerInterfaceWrapper) GetUsers(ctx echo.Context) error

GetUsers converts echo context to params.

type User

type User struct {
	Email    string              `json:"email"`
	Id       *openapi_types.UUID `json:"id,omitempty"`
	Name     string              `json:"name"`
	Password string              `json:"password"`
}

User defines model for User.

type UserRepository

type UserRepository interface {
	AddUser(ctx context.Context, user models.User) error
}

type Users

type Users = []User

Users defines model for Users.

Jump to

Keyboard shortcuts

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