modulepackage
0.0.0-20240927004532-6972f81793f0
Repository: https://github.com/legendaryllama37/go-api.git
Documentation: pkg.go.dev
# README
go-api
golang production ready api
curl -X POST http://localhost:8080/process
-H "Authorization: Bearer JWT_TOKEN"
-H "Content-Type: application/json"
-d '{"key": "value"}'
# Functions
GenerateToken creates a JWT token for a user.
@Summary Login User to retrieve token @Description Authenticates the user and returns a JWT token @Tags auth @Accept application/x-www-form-urlencoded @Produce application/json @Param username formData string true "Username" @Param password formData string true "Password" @Success 200 {string} string "token" @Failure 401 {string} string "Invalid credentials" @Router /login [post].
@Summary Get application stats @Description Returns the request count @Tags stats @Produce json @Success 200 {object} map[string]int @Router /stats [get].
JWTMiddleware returns a middleware handler that validates JWT tokens.
NewAPIConfig creates a new APIConfig with default values and applies options.
@Summary Process payload @Description Process JSON payload with JWT token @Tags payload @Accept json @Produce json @Param Authorization header string true "Bearer token" default(Bearer <token>) @Param payload body map[string]interface{} true "JSON payload" @Success 200 {object} map[string]interface{} "The processed payload" @Failure 401 {string} string "Unauthorized" @Security BearerAuth @Router /process [post].
No description provided by the author
No description provided by the author
WithSecretKey sets the JWT secret key.
WithTokenExpiration sets the JWT token expiration duration.
# Type aliases
Option is a function that configures APIConfig.