pyrin

package module
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 6 Imported by: 3

README

pyrin

REST API Framework

Goals

  • API Server (Using Echo)
  • Schema Validation
  • Generate Spec File
  • API Client Generation
    • Golang
    • Typescript
  • API Docs Generation

Documentation

Index

Constants

View Source
const ErrTypeUnknownError api.ErrorType = "UNKNOWN_ERROR"

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiHandler added in v0.8.1

type ApiHandler struct {
	Name        string
	Method      string
	Path        string
	DataType    any
	BodyType    Body
	RequireForm bool
	Errors      []api.ErrorType
	Middlewares []echo.MiddlewareFunc
	HandlerFunc ApiHandlerFunc
}

type ApiHandlerFunc added in v0.8.1

type ApiHandlerFunc func(c Context) (any, error)

type Body

type Body interface {
	validate.Validatable
}

type Context

type Context interface {
	Request() *http.Request
	Response() http.ResponseWriter
	Param(name string) string
}

type Group

type Group interface {
	Register(handlers ...Handler)
}

type Handler

type Handler interface {
	// contains filtered or unexported methods
}

type NormalHandler added in v0.8.1

type NormalHandler struct {
	Method      string
	Path        string
	Middlewares []echo.MiddlewareFunc
	HandlerFunc NormalHandlerFunc
}

type NormalHandlerFunc added in v0.8.1

type NormalHandlerFunc func(c Context) error

type Route

type Route struct {
	Name        string
	Path        string
	Method      string
	ErrorTypes  []api.ErrorType
	Data        any
	Body        any
	RequireForm bool
}

type RouteGroup

type RouteGroup struct {
	Prefix string
	Routes []Route
}

func NewRouteGroup

func NewRouteGroup(prefix string) *RouteGroup

func (*RouteGroup) Register

func (r *RouteGroup) Register(handlers ...Handler)

type Router

type Router interface {
	Group(prefix string) Group
}

type Server

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

func NewServer

func NewServer(config *ServerConfig) *Server

func (*Server) Group

func (s *Server) Group(prefix string, m ...echo.MiddlewareFunc) *ServerGroup

func (*Server) Start

func (s *Server) Start(addr string) error

type ServerConfig

type ServerConfig struct {
	RegisterHandlers func(router Router)
	LogName          string
}

type ServerGroup

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

func (*ServerGroup) Register

func (g *ServerGroup) Register(handlers ...Handler)

type ServerRouter

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

func (*ServerRouter) Group

func (r *ServerRouter) Group(prefix string) Group

Directories

Path Synopsis
client
gen
cmd
tools
ast

Jump to

Keyboard shortcuts

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