Documentation
¶
Index ¶
- Variables
- func ApiKeyAuthHandler(_ context.Context, ...) (*simbaModels.Response[simbaModels.NoBody], error)
- func BasicAuthHandler(_ context.Context, ...) (*simbaModels.Response[simbaModels.NoBody], error)
- func BearerTokenAuthHandler(ctx context.Context, ...) (*simbaModels.Response[simbaModels.NoBody], error)
- func DeprecatedHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
- func NoTagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
- func SessionCookieAuthHandler(_ context.Context, ...) (*simbaModels.Response[simbaModels.NoBody], error)
- func TagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
- type AuthRequestBody
- type Params
- type Receiver
- func (h *Receiver) DeprecatedHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
- func (h *Receiver) NoTagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
- func (h *Receiver) TagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
- type RequestBody
- type ResponseBody
- type TestApplication
- type User
Constants ¶
This section is empty.
Variables ¶
var ApiKeyAuthAuthenticationHandler = simba.APIKeyAuth[User]( ApiKeyAuthFunc, simba.APIKeyAuthConfig{ Name: "User", FieldName: "sessionid", In: openapi.InCookie, Description: "Session cookie", })
var BasicAuthAuthenticationHandler = simba.BasicAuth[User]( BasicAuthFunc, simba.BasicAuthConfig{ Name: "admin", Description: "admin access only", })
var BearerAuthAuthenticationHandler = simba.BearerAuth[User]( BearerAuthFunc, simba.BearerAuthConfig{ Name: "admin", Format: "jwt", Description: "Bearer token", })
var SessionCookieAuthAuthenticationHandler = simba.SessionCookieAuth[User]( SessionCookieAuthFunc, simba.SessionCookieAuthConfig[User]{ CookieName: "session", Description: "Session cookie", }, )
Functions ¶
func ApiKeyAuthHandler ¶ added in v0.15.0
func ApiKeyAuthHandler(_ context.Context, req *simbaModels.Request[simbaModels.NoBody, simbaModels.NoParams], auth *User) (*simbaModels.Response[simbaModels.NoBody], error)
ApiKeyAuthHandler A dummy function to test the OpenAPI generation with api key auth. @ID apiKeyAuthHandler @Summary api key handler @Description this is a multiline
description for the handler
@Error 409 Resource already exists
func BasicAuthHandler ¶ added in v0.15.0
func BasicAuthHandler(_ context.Context, req *simbaModels.Request[simbaModels.NoBody, simbaModels.NoParams], auth *User) (*simbaModels.Response[simbaModels.NoBody], error)
BasicAuthHandler A dummy function to test the OpenAPI generation with basic auth. @ID basicAuthHandler @Summary basic auth handler @Description this is a multiline
description for the handler
@Error 409 Resource already exists
func BearerTokenAuthHandler ¶ added in v0.15.0
func BearerTokenAuthHandler(ctx context.Context, req *simbaModels.Request[simbaModels.NoBody, simbaModels.NoParams], auth *User) (*simbaModels.Response[simbaModels.NoBody], error)
BearerTokenAuthHandler A dummy function to test the OpenAPI generation with bearer token auth. @ID bearerTokenAuthHandler @Summary bearer token handler @Description this is a multiline
description for the handler
@Error 409 Resource already exists
func DeprecatedHandler ¶ added in v0.16.0
func DeprecatedHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
DeprecatedHandler A dummy function to test the OpenAPI generation with deprecated tag. @Deprecated
func NoTagsHandler ¶ added in v0.15.0
func NoTagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
NoTagsHandler A dummy function to test the OpenAPI generation without any tags in the comment.
func SessionCookieAuthHandler ¶ added in v0.18.0
func SessionCookieAuthHandler(_ context.Context, req *simbaModels.Request[simbaModels.NoBody, simbaModels.NoParams], auth *User) (*simbaModels.Response[simbaModels.NoBody], error)
SessionCookieAuthHandler A dummy function to test the OpenAPI generation with session cookie auth. @ID sessionCookieAuthHandler @Summary session cookie handler @Description this is a multiline
description for the handler
@Error 409 Resource already exists
func TagsHandler ¶ added in v0.15.0
func TagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
TagsHandler A dummy function to test the OpenAPI generation with tags in the comment. @ID testHandler @Tag Test @Tag User @Summary test handler @Description this is a multiline @StatusCode 201
description for the handler @Error 409 Resource already exists
Types ¶
type AuthRequestBody ¶ added in v0.15.0
type AuthRequestBody struct {
Token string `json:"token" validate:"required"`
}
AuthRequestBody is a test struct for authenticated request body
type Params ¶ added in v0.15.0
type Params struct {
ID uuid.UUID `path:"id" description:"ID of the user" example:"1"`
Gender string `query:"gender" description:"Gender of the user" example:"male"`
RequestID string `header:"X-Request-ID" description:"Request ID" example:"1234"`
Active bool `query:"active" description:"Active status of the user" example:"true"`
Page int `query:"page" description:"Page number" example:"1" default:"1"`
Size int64 `query:"size" description:"Page size" example:"10" default:"10"`
Score float64 `query:"score" description:"User score" example:"9.5" default:"10.0"`
}
type Receiver ¶ added in v0.15.0
type Receiver struct{}
Receiver A dummy struct to test the OpenAPI generation with receiver functions.
func (*Receiver) DeprecatedHandler ¶ added in v0.16.0
func (h *Receiver) DeprecatedHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
DeprecatedHandler A dummy function to test the OpenAPI generation with deprecated tag. @Deprecated
func (*Receiver) NoTagsHandler ¶ added in v0.15.0
func (h *Receiver) NoTagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
NoTagsHandler A dummy function to test the OpenAPI generation without any tags in the comment.
func (*Receiver) TagsHandler ¶ added in v0.15.0
func (h *Receiver) TagsHandler(ctx context.Context, req *simbaModels.Request[RequestBody, Params]) (*simbaModels.Response[ResponseBody], error)
TagsHandler A dummy function to test the OpenAPI generation with tags in the comment with receiver functions. @ID testHandler @Deprecated @Tag Test @Tag User @Summary test handler @Description this is a multiline
description for the handler @Error 409 Resource already exists
type RequestBody ¶ added in v0.15.0
type ResponseBody ¶ added in v0.15.0
type ResponseBody struct {
ID uuid.UUID `json:"id" description:"ID of the user" example:"1"`
Name string `json:"name" description:"Name of the user" example:"John Doe"`
Age int `json:"age" description:"Age of the user" example:"30"`
Description string `json:"description" description:"description of the user" example:"A test user"`
}
type TestApplication ¶
type TestApplication struct {
*simba.Application
Server *httptest.Server
}
TestApplication represents a test application with additional testing utilities
func Default ¶ added in v0.10.0
func Default(opts ...settings.Option) *TestApplication
Default creates a new test application with default settings
func New ¶
func New(opts ...settings.Option) *TestApplication
New creates a new test application with the given settings
func (*TestApplication) Client ¶
func (a *TestApplication) Client() *http.Client
Client returns an HTTP client configured to work with the test server
func (*TestApplication) RunTest ¶
func (a *TestApplication) RunTest(fn func())
RunTest runs a test function with a started test server and handles cleanup
func (*TestApplication) URL ¶
func (a *TestApplication) URL() string
URL returns the base URL of the test server
type User ¶ added in v0.15.0
type User struct {
ID int `json:"id" description:"ID of the user" example:"1"`
Name string `json:"name" description:"Name of the user" example:"John Doe"`
Role string `json:"role" description:"Role of the user" example:"admin"`
}
func ApiKeyAuthFunc ¶ added in v0.15.0
ApiKeyAuthFunc A dummy function to test the OpenAPI generation with api key auth. @APIKeyAuth "User" "sessionid" "cookie" "Session cookie"
func BasicAuthFunc ¶ added in v0.15.0
func BearerAuthFunc ¶ added in v0.15.0
BearerAuthFunc A dummy function to test the OpenAPI generation with bearer token auth. @BearerAuth "admin" "jwt" "Bearer token"