sfw

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIGen

type APIGen = hureg.APIGen

type BaseResponseData

type BaseResponseData[T any] struct {
	Message string `json:"message"`
	Data    T      `json:"data"`
}

BaseResponseData is a wrapper for api response

type CleanupJob

type CleanupJob struct {
	Name string
	Func func(context.Context) error
}

type EmptyRequestBody

type EmptyRequestBody = struct {
	Lang string `header:"Accept-Language"`
}

EmptyRequestBody is an alias for *struct{}

type EmptyResponseData

type EmptyResponseData = *struct{}

EmptyResponseData is an alias for *struct{}

type Request

type Request[T any] struct {
	Lang string `header:"Accept-Language"`
	Body T
}

Request represent the base request in the application

type ResponseData

type ResponseData[T any] struct {
	Body BaseResponseData[T]
}

ResponseData is a client response. This must have Body property to fullfill huma.API standard

func RespondMsg

func RespondMsg(msg string) *ResponseData[EmptyResponseData]

RespondOKWith will generate response but only {"message": "Your message here"}

func RespondOK

func RespondOK() *ResponseData[EmptyResponseData]

RespondOK will generate ok but only {"message": "OK"}

func RespondOKWith

func RespondOKWith[T any](response T) *ResponseData[T]

RespondOKWith will generate response along with data

type Server

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

func NewServer

func NewServer(title, version string, isDevelopmentMode bool) Server

NewServer will create struct contains huma.API and *echo.Echo

func (*Server) API

func (s *Server) API() huma.API

API represents a Huma API wrapping a specific router.

func (*Server) Group

func (s *Server) Group(basePath string, groupFunc func(APIGen))

Group create a new route group. It is recommended that you dont call APIGen.AddBasePath again, because that is already handled for you.

func (*Server) Start

func (s *Server) Start(port string)

Start starts an HTTP server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context, jobs ...CleanupJob)

Stop will stop the server is the signal channel is received. If not this will block forever

func (*Server) Use

func (s *Server) Use(middlewares ...echo.MiddlewareFunc)

Use adds middleware to the chain which is run after router.

Directories

Path Synopsis
cmd
sfw

Jump to

Keyboard shortcuts

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