unalcohol

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultStatusBadRequest added in v0.0.3

func DefaultStatusBadRequest(r *http.Request, w http.ResponseWriter) error

func DefaultStatusInternalServerError added in v0.0.3

func DefaultStatusInternalServerError(r *http.Request, w http.ResponseWriter) error

func DefaultStatusMethodNotAllowed added in v0.0.3

func DefaultStatusMethodNotAllowed(r *http.Request, w http.ResponseWriter) error

func JoinPath added in v0.0.3

func JoinPath(ptr API, url string) string

Types

type API

type API interface {
	GetPath() string
	GetPtr() API
}

type BaseAPI added in v0.0.3

type BaseAPI struct {
	Path string
	Tags []string
}

func (*BaseAPI) GetPath added in v0.0.3

func (a *BaseAPI) GetPath() string

func (*BaseAPI) GetPtr added in v0.0.3

func (a *BaseAPI) GetPtr() API

func (*BaseAPI) Middleware added in v0.0.4

func (a *BaseAPI) Middleware(r *http.Request, resp http.ResponseWriter) error

type Body

type Body[T any] struct {
	Value T
}

func (*Body[T]) Doc added in v0.0.3

func (b *Body[T]) Doc(key string, operation *openapi3.Operation) error

func (*Body[T]) ParseRequest

func (b *Body[T]) ParseRequest(key string, r *http.Request, resp http.ResponseWriter) (err error)
type Header[T any] struct {
	Value T
}

func (*Header[T]) Doc added in v0.0.3

func (p *Header[T]) Doc(key string, operation *openapi3.Operation) error

func (*Header[T]) ParseRequest

func (h *Header[T]) ParseRequest(key string, r *http.Request, resp http.ResponseWriter) (err error)

type IOResponse

type IOResponse struct {
	Code int
	Data io.ReadCloser
}

func (*IOResponse) Doc added in v0.0.6

func (r *IOResponse) Doc(operation *openapi3.Operation) error

func (*IOResponse) WriteResponse

func (r *IOResponse) WriteResponse(w http.ResponseWriter) error

type JSON

type JSON[T any] struct {
	Value T
}

func (*JSON[T]) Doc added in v0.0.3

func (j *JSON[T]) Doc(key string, operation *openapi3.Operation) error

func (*JSON[T]) ParseRequest

func (j *JSON[T]) ParseRequest(key string, r *http.Request, resp http.ResponseWriter) (err error)

type JSONResponse

type JSONResponse[T any] struct {
	Code int
	Data T
}

func (*JSONResponse[T]) Doc added in v0.0.3

func (r *JSONResponse[T]) Doc(operation *openapi3.Operation) error

func (*JSONResponse[T]) WriteResponse

func (r *JSONResponse[T]) WriteResponse(w http.ResponseWriter) error

type Middleware added in v0.0.3

type Middleware = func(*http.Request, http.ResponseWriter) error

type Param

type Param[T any] struct {
	Value T
}

func (*Param[T]) Doc added in v0.0.3

func (p *Param[T]) Doc(key string, operation *openapi3.Operation) error

func (*Param[T]) ParseRequest

func (p *Param[T]) ParseRequest(key string, r *http.Request, resp http.ResponseWriter) (err error)

type Path

type Path[T int | string | float32 | float64 | int64] struct {
	Value T
}

func (*Path[T]) Doc added in v0.0.3

func (p *Path[T]) Doc(key string, operation *openapi3.Operation) error

func (*Path[T]) ParseRequest

func (p *Path[T]) ParseRequest(key string, r *http.Request, resp http.ResponseWriter) (err error)

type Request

type Request struct {
	Value *http.Request
}

func (*Request) Doc added in v0.0.3

func (r *Request) Doc(key string, operation *openapi3.Operation) error

func (*Request) ParseRequest

func (r *Request) ParseRequest(key string, req *http.Request, resp http.ResponseWriter) (err error)

type Response

type Response struct {
	Value http.ResponseWriter
}

func (*Response) Doc added in v0.0.3

func (r *Response) Doc(key string, operation *openapi3.Operation) error

func (*Response) ParseRequest

func (r *Response) ParseRequest(key string, req *http.Request, resp http.ResponseWriter) (err error)

type ResponseInf

type ResponseInf interface {
	WriteResponse(http.ResponseWriter) error
}

type Server

type Server struct {
	Mux  *http.ServeMux
	Addr string

	StatusBadRequest          Middleware
	StatusMethodNotAllowed    Middleware
	StatusInternalServerError Middleware
	// contains filtered or unexported fields
}

func New added in v0.0.3

func New(address string) *Server

func (*Server) GetMux

func (srv *Server) GetMux() *http.ServeMux

func (*Server) Middleware added in v0.0.3

func (srv *Server) Middleware(r *http.Request, resp http.ResponseWriter) error

func (*Server) Start

func (srv *Server) Start() error

Directories

Path Synopsis
cmd
internal
doc

Jump to

Keyboard shortcuts

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