swift

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Swift

Go Report Card

Light abstraction on top of std http library built for personal use to avoid reaching for frameworks 💩

Documentation

Index

Constants

View Source
const (
	DEV_FRONTEND_PROXY = "DEV_FRONTEND_PROXY"
)

Variables

View Source
var BuiltInMiddlewares = []Middleware{RecoverMiddleware}
View Source
var ContextValue = Context{
	// contains filtered or unexported fields
}

Functions

func Boot

func Boot(r *Swift)

func BuildAndValidatePath

func BuildAndValidatePath(path string) string

func HealthCheckHandler

func HealthCheckHandler(w http.ResponseWriter, r *http.Request)

func MakeMiddlewareStack

func MakeMiddlewareStack(h http.Handler, m []Middleware) http.Handler

func MiddlewareStack

func MiddlewareStack(handler http.Handler, middlewares ...Middleware) http.Handler

func NotFoundHandler

func NotFoundHandler(w http.ResponseWriter, r *http.Request)

func Prepend

func Prepend[T any](slice []T, elems ...T) []T

func RecoverMiddleware

func RecoverMiddleware(next http.Handler) http.Handler

func ValidateOApiSchemaMiddleware

func ValidateOApiSchemaMiddleware(next http.Handler) http.Handler

Types

type Context

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

func GetContext

func GetContext() *Context

type Group

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

func (*Group) Delete

func (g *Group) Delete(path string, handler http.HandlerFunc) *HandlerValue

func (*Group) Get

func (g *Group) Get(path string, handler http.HandlerFunc) *HandlerValue

func (*Group) Group

func (g *Group) Group(path string) *Group

func (*Group) Middleware

func (g *Group) Middleware(m ...Middleware) *Group

func (*Group) Patch

func (g *Group) Patch(path string, handler http.HandlerFunc) *HandlerValue

func (*Group) Post

func (g *Group) Post(path string, handler http.HandlerFunc) *HandlerValue

func (*Group) Put

func (g *Group) Put(path string, handler http.HandlerFunc) *HandlerValue

type HandlerValue

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

func (*HandlerValue) Middleware

func (h *HandlerValue) Middleware(m ...Middleware)

type Middleware

type Middleware func(http.Handler) http.Handler

type StaticServer added in v0.2.0

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

type SwaggerServer

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

type Swift

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

func New

func New() *Swift

func (*Swift) AddCorsMiddleware added in v0.2.2

func (r *Swift) AddCorsMiddleware(f func(next http.Handler) http.Handler)

func (*Swift) AddTLS

func (r *Swift) AddTLS(crt, key string)

func (*Swift) ApiPrefix added in v0.2.0

func (r *Swift) ApiPrefix() *Group

func (*Swift) Custom404

func (r *Swift) Custom404(c func(w http.ResponseWriter))

func (*Swift) Custom500

func (r *Swift) Custom500(c func(w http.ResponseWriter))

func (*Swift) Delete

func (r *Swift) Delete(pth string, handler http.HandlerFunc) *HandlerValue

func (*Swift) Get

func (r *Swift) Get(pth string, handler http.HandlerFunc) *HandlerValue

func (*Swift) Group

func (r *Swift) Group(path string) *Group

func (*Swift) Handle

func (r *Swift) Handle(pth string, handler http.Handler)

func (*Swift) MakeHandler

func (r *Swift) MakeHandler(m, path string, handler http.HandlerFunc, group *Group) *HandlerValue

func (*Swift) Middleware

func (r *Swift) Middleware(m ...Middleware)

func (*Swift) OApiValidator

func (r *Swift) OApiValidator(pathToSchema string)

func (*Swift) OnBoot

func (r *Swift) OnBoot(f func())

func (*Swift) Patch

func (r *Swift) Patch(pth string, handler http.HandlerFunc) *HandlerValue

func (*Swift) Post

func (r *Swift) Post(pth string, handler http.HandlerFunc) *HandlerValue

func (*Swift) Put

func (r *Swift) Put(pth string, handler http.HandlerFunc) *HandlerValue

func (*Swift) RootStaticServer added in v0.2.0

func (r *Swift) RootStaticServer(staticDir string, spa bool)

func (*Swift) Serve

func (r *Swift) Serve(host, port string)

func (*Swift) SetApiPrefix added in v0.2.0

func (r *Swift) SetApiPrefix(prefix string)

func (*Swift) SwaggerServe

func (r *Swift) SwaggerServe(serve bool)

func (*Swift) SwaggerStaticServer

func (r *Swift) SwaggerStaticServer(staticDir, path string)

type TLS

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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