Documentation
¶
Index ¶
- type ApiResponse
- type App
- func (a App) DELETE(path string, handler Handler, opt ...RouteOption)
- func (a *App) GET(path string, handler Handler, opt ...RouteOption)
- func (a *App) NewRouter(path string) *Router
- func (a App) OPTIONS(path string, handler Handler, opt ...RouteOption)
- func (a App) POST(path string, handler Handler, opt ...RouteOption)
- func (a App) PUT(path string, handler Handler, opt ...RouteOption)
- func (a *App) Run() error
- func (a App) ServeStaticDir(urlPath, dirPath string)
- func (a App) ServeStaticFile(urlPath, filePath string, opt ...StaticServFileOption)
- func (a *App) SetDefaultRoute(handler Handler)
- func (a *App) SetLogger(logger logger.Logger)
- type AppConfig
- type AppOption
- func AppAddServer(url, description string) AppOption
- func AppAddr(host, port string) AppOption
- func AppContact(name, email, url string) AppOption
- func AppDescription(description string) AppOption
- func AppLicense(name, url string) AppOption
- func AppLogger(logger logger.Logger) AppOption
- func AppTitle(title string) AppOption
- func AppVersion(version string) AppOption
- type CORSConfig
- type Ctx
- type Endpoint
- type ErrorResponse
- type Handler
- type Middleware
- type RequestMethod
- type Response
- type Route
- type RouteOption
- func WithObjIn(obj any) RouteOption
- func WithObjOut(obj any) RouteOption
- func WithOpenApiDeprecated() RouteOption
- func WithOpenApiDisabled() RouteOption
- func WithOpenApiEnabled(summary, description string) RouteOption
- func WithOpenApiInfos(summary, description string) RouteOption
- func WithOpenApiTags(tags ...string) RouteOption
- type RouteOptionConfig
- type Router
- func (r *Router) DELETE(path string, handler Handler, opt ...RouteOption)
- func (r *Router) GET(path string, handler Handler, opt ...RouteOption)
- func (r Router) GetBasePath() string
- func (r *Router) OPTIONS(path string, handler Handler, opt ...RouteOption)
- func (r *Router) POST(path string, handler Handler, opt ...RouteOption)
- func (r *Router) PUT(path string, handler Handler, opt ...RouteOption)
- func (r *Router) ServeStaticDir(urlPath, dirPath string, a App)
- func (r *Router) ServeStaticFile(urlPath, filePath string, opt ...StaticServFileOption) error
- type StaticServFileOption
- type StaticSevFileConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiResponse ¶
type ApiResponse struct {
Headers map[string]string
StatusCode int `json:"statusCode" xml:"statusCode"`
InternalErrorCode int ``
Message string `json:"message" xml:"message"`
Data []byte `json:"data,omitempty" xml:"data,omitempty"`
}
func NewApiResponse ¶
func NewApiResponse() ApiResponse
func (*ApiResponse) AddHeader ¶
func (r *ApiResponse) AddHeader(k, v string)
func (*ApiResponse) SendingReturn ¶
func (r *ApiResponse) SendingReturn(w http.ResponseWriter, c *Ctx, err error)
func (*ApiResponse) SetData ¶
func (r *ApiResponse) SetData(data []byte)
func (*ApiResponse) SetMessage ¶
func (r *ApiResponse) SetMessage(msg string)
func (*ApiResponse) SetStatus ¶
func (r *ApiResponse) SetStatus(code int)
type App ¶
TODO: Add Timeout handling (Middleware??) TODO: Add MaxConnection handling (Middleware??) TODO: Add RateLimit handling (Middleware??)
func (App) ServeStaticDir ¶ added in v0.3.3
func (App) ServeStaticFile ¶ added in v0.3.3
func (a App) ServeStaticFile(urlPath, filePath string, opt ...StaticServFileOption)
func (*App) SetDefaultRoute ¶
type AppConfig ¶
type AppConfig struct {
// contains filtered or unexported fields
}
func (AppConfig) GetListenAddress ¶
type AppOption ¶
type AppOption func(*AppConfig)
func AppAddServer ¶
func AppContact ¶
func AppDescription ¶
func AppLicense ¶
func AppVersion ¶
type CORSConfig ¶
type CORSConfig struct {
// AllowOrigins is a list of origins a cross-domain request can be executed from.
// If the special "*" value is present in the list, all origins will be allowed.
// Default value is ["*"]
AllowOrigins []string
// AllowMethods is a list of methods the client is allowed to use with
// cross-domain requests. Default value is simple methods (GET, POST, PUT, DELETE)
AllowMethods []string
// AllowHeaders is a list of non-simple headers the client is allowed to use with
// cross-domain requests. Default value is []
AllowHeaders []string
// ExposeHeaders indicates which headers are safe to expose to the API of a CORS
// API specification. Default value is []
ExposeHeaders []string
// AllowCredentials indicates whether the request can include user credentials like
// cookies, HTTP authentication or client side SSL certificates. Default is false.
AllowCredentials bool
// MaxAge indicates how long (in seconds) the results of a preflight request
// can be cached. Default is 0 which stands for no max age.
MaxAge int
}
CORSConfig holds the configuration for CORS middleware
func DefaultCORSConfig ¶
func DefaultCORSConfig() CORSConfig
DefaultCORSConfig returns a default CORS configuration
type Ctx ¶
type ErrorResponse ¶
type Middleware ¶
func CORSMiddleware ¶
func CORSMiddleware(config CORSConfig) Middleware
CORSMiddleware returns a middleware that handles CORS
func LogMiddleware ¶
func LogMiddleware(logger logger.Logger) Middleware
func PanicMiddleware ¶
func PanicMiddleware() Middleware
type RequestMethod ¶
type RequestMethod int
const ( METHOD_GET RequestMethod = iota METHOD_POST METHOD_PUT METHOD_PATCH METHOD_DELETE METHOD_HEAD METHOD_OPTIONS METHOD_TRACE METHOD_CONNECT )
type RouteOption ¶
type RouteOption func(*RouteOptionConfig)
func WithObjIn ¶
func WithObjIn(obj any) RouteOption
func WithObjOut ¶
func WithObjOut(obj any) RouteOption
func WithOpenApiDeprecated ¶
func WithOpenApiDeprecated() RouteOption
func WithOpenApiDisabled ¶
func WithOpenApiDisabled() RouteOption
func WithOpenApiEnabled ¶
func WithOpenApiEnabled(summary, description string) RouteOption
func WithOpenApiInfos ¶
func WithOpenApiInfos(summary, description string) RouteOption
func WithOpenApiTags ¶
func WithOpenApiTags(tags ...string) RouteOption
type RouteOptionConfig ¶
TODO: Add this to Router as well and set the Router values as default for Route
func NewRouteOptionConfig ¶
func NewRouteOptionConfig(opts ...RouteOption) *RouteOptionConfig
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (Router) GetBasePath ¶
func (*Router) ServeStaticDir ¶ added in v0.3.3
TODO: Rethink/Implement do use more of the Framework
func (*Router) ServeStaticFile ¶ added in v0.3.3
func (r *Router) ServeStaticFile(urlPath, filePath string, opt ...StaticServFileOption) error
type StaticServFileOption ¶ added in v0.3.3
type StaticServFileOption func(*StaticSevFileConfig)
func WithContentType ¶ added in v0.3.3
func WithContentType(contentType string) StaticServFileOption
func WithPreCache ¶ added in v0.3.3
func WithPreCache() StaticServFileOption
type StaticSevFileConfig ¶ added in v0.3.3
type StaticSevFileConfig struct {
// contains filtered or unexported fields
}
func NewStaticServeFileConfig ¶ added in v0.3.3
func NewStaticServeFileConfig(opts ...StaticServFileOption) *StaticSevFileConfig
Click to show internal directories.
Click to hide internal directories.