Documentation
¶
Overview ¶
This package is designed for defining and managing HTTP APIs, with a focus on simplifying the API creation process and providing auto-generated API documentation. By using a declarative syntax, users can easily define API endpoints, request parameters, and response formats while automatically generating detailed API documentation.
Key Features ¶
- Declarative API Definition: Define API paths, methods, and handlers using a clean, declarative syntax.
- Automatic API Documentation: Automatically generates documentation based on the API definitions, reducing the need for manual documentation maintenance.
- Parameter Validation: Supports request parameter validation and documentation, ensuring API robustness.
- Error Handling: Built-in error handling mechanism provides friendly responses for invalid requests and errors.
Index ¶
- func AllowCookie(yesno bool)
- func IsCookieAllowed() bool
- func LoadLanguage(tag language.Tag, trans map[string]string)
- func RawReply(code int) *reply
- func Register(a API, mx ...*http.ServeMux)
- func Reply(code int) *reply
- func SetGlobalCORS(enable bool, origin ...string)
- func WithGlobalActions(as ...Action)
- func WithLangSpecifier(lang string)
- func WithPanicLogger(f func(mesg string, trace []string))
- type API
- type Action
- type ApiSpec
- type NetRange
- type ParamSpec
- type ReplyDesc
- type ReplySpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
Action represents a function signature used for handling HTTP requests within the hap package. It defines a callback function that takes three parameters:
- *arg.Args: A pointer to the arguments parsed from the request. See the documentation for arg.Args for more details.
- http.ResponseWriter: An interface used to construct the HTTP response.
- *http.Request: A pointer to the HTTP request being handled.
The function returns `any`, which allows it to return various types of responses depending on the logic implemented. This type is typically used to define the logic for processing HTTP requests and generating responses based on the request parameters and other conditions.
type ApiSpec ¶
type NetRange ¶
type NetRange struct {
// contains filtered or unexported fields
}
func (*NetRange) IsTrustedRequest ¶
type ParamSpec ¶
type ReplyDesc ¶
type ReplySpec ¶
type ReplySpec = *reply