Documentation ¶
Index ¶
- func HTTPException(httpCode int, detail string, headers ...map[string]string)
- func SetLogLevel(level LogLevel)
- type API
- func (a *API) AddMiddleware(middlewares ...Middleware)
- func (a *API) DebugPprof()
- func (a *API) HTTPExceptionHandler(f func(httpCode int, detail string) Response)
- func (a *API) IncludeRouter(router any, prefix string, isDocs bool, middlewares ...Middleware)
- func (a *API) Run(addr ...string)
- func (a *API) SetLang(lang Lang)
- func (a *API) SetLogger(log Logger)
- func (a *API) SetResponseMediaType(mediaTypes ...MediaType)
- func (a *API) Static(path, root string)
- type APP
- type ApiKey
- type Context
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Get(key string) (value any, ok bool)
- func (c *Context) Logger() Logger
- func (c *Context) Next()
- func (c *Context) Set(key string, value any)
- func (c *Context) Value(key any) any
- type HTTPBasic
- type HTTPBearer
- type HTTPResponse
- type Lang
- type LogLevel
- type Logger
- type MediaType
- type Middleware
- type Response
- type ResponseWriter
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLogLevel ¶ added in v0.0.2
func SetLogLevel(level LogLevel)
Types ¶
type API ¶
type API struct { OpenAPIInfo *openapi.Info OpenAPIServers []*openapi.Server OpenAPITags []*openapi.Tag // contains filtered or unexported fields }
func (*API) AddMiddleware ¶
func (a *API) AddMiddleware(middlewares ...Middleware)
AddMiddleware It is a function for adding middleware
func (*API) DebugPprof ¶ added in v0.0.4
func (a *API) DebugPprof()
DebugPprof Open the system's built-in pprof
func (*API) HTTPExceptionHandler ¶
HTTPExceptionHandler It is an exception handling registration for HTTP
func (*API) IncludeRouter ¶
func (a *API) IncludeRouter(router any, prefix string, isDocs bool, middlewares ...Middleware)
IncludeRouter It is a function that introduces routing structures
func (*API) SetResponseMediaType ¶
SetResponseMediaType It is a function that sets the return value type
type Context ¶
type HTTPBasic ¶
type HTTPBasic interface {
HTTPBasic(username, password string)
}
HTTPBasic verification interface
type HTTPBearer ¶
type HTTPBearer interface {
HTTPBearer(token string)
}
HTTPBearer verification interface
type HTTPResponse ¶
func (*HTTPResponse[T]) Bytes ¶
func (h *HTTPResponse[T]) Bytes() []byte
func (*HTTPResponse[T]) GetBody ¶
func (h *HTTPResponse[T]) GetBody() any
func (*HTTPResponse[T]) GetHeaders ¶
func (h *HTTPResponse[T]) GetHeaders() map[string]string
func (*HTTPResponse[T]) GetHttpCode ¶
func (h *HTTPResponse[T]) GetHttpCode() int
type Lang ¶
type Lang interface { Required(field string) string Lt(field string, val float64) string Lte(field string, val float64) string Gt(field string, val float64) string Gte(field string, val float64) string MultipleOf(field string, val float64) string Max(field string, val uint64) string Min(field string, val uint64) string Unique(field string) string Regexp(field string, val string) string Enum(field string, val []any) string }
type MediaType ¶
type MediaType string
const JSON MediaType = "application/json"
const XML MediaType = "application/xml"
type Middleware ¶
type Middleware func(ctx *Context)
type ResponseWriter ¶ added in v0.0.2
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func (*ResponseWriter) Flush ¶ added in v0.0.3
func (r *ResponseWriter) Flush()
Flush implements the http.Flusher interface.
func (*ResponseWriter) Header ¶ added in v0.0.2
func (r *ResponseWriter) Header() http.Header
func (*ResponseWriter) Hijack ¶ added in v0.0.3
func (r *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack implements the http.Hijacker interface.
func (*ResponseWriter) Status ¶ added in v0.0.2
func (r *ResponseWriter) Status() int
func (*ResponseWriter) Write ¶ added in v0.0.2
func (r *ResponseWriter) Write(b []byte) (int, error)
func (*ResponseWriter) WriteHeader ¶ added in v0.0.2
func (r *ResponseWriter) WriteHeader(statusCode int)
type Router ¶
type Router struct{}
Router is used to set access routes and routing methods
Tag Description: path: Access Routing method: Access method. Multiple contents separated by ',' summary: A short summary of the API. desc: A description of the API. CommonMark syntax MAY be used for rich text representation. tags: Multiple contents separated by ','
Source Files ¶
Click to show internal directories.
Click to hide internal directories.