mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-07-14 14:01:34 +00:00
feat: add option to disable scalar
This commit is contained in:
@@ -89,11 +89,13 @@ func (app *BootstrapApp) setupRouter() error {
|
|||||||
return fmt.Errorf("failed to provide api router group: %w", err)
|
return fmt.Errorf("failed to provide api router group: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app.config.Server.ScalarEnabled {
|
||||||
err = app.setupScalar()
|
err = app.setupScalar()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to setup scalar: %w", err)
|
return fmt.Errorf("failed to setup scalar: %w", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
controllerProvideFor := []any{
|
controllerProvideFor := []any{
|
||||||
controller.NewContextController,
|
controller.NewContextController,
|
||||||
|
|||||||
@@ -35,6 +35,6 @@ func NewHealthController(i HealthControllerInput) *HealthController {
|
|||||||
func (controller *HealthController) healthHandler(c *gin.Context) {
|
func (controller *HealthController) healthHandler(c *gin.Context) {
|
||||||
c.JSON(200, SimpleResponse{
|
c.JSON(200, SimpleResponse{
|
||||||
Status: 200,
|
Status: 200,
|
||||||
Message: "OK",
|
Message: "Healthy",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ func TestHealthController(t *testing.T) {
|
|||||||
path: "/api/healthz",
|
path: "/api/healthz",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
expected: func() string {
|
expected: func() string {
|
||||||
expectedHealthResponse := map[string]any{
|
expectedHealthResponse := SimpleResponse{
|
||||||
"status": 200,
|
Status: 200,
|
||||||
"message": "Healthy",
|
Message: "Healthy",
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(expectedHealthResponse)
|
bytes, err := json.Marshal(expectedHealthResponse)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -37,9 +37,9 @@ func TestHealthController(t *testing.T) {
|
|||||||
path: "/api/healthz",
|
path: "/api/healthz",
|
||||||
method: "HEAD",
|
method: "HEAD",
|
||||||
expected: func() string {
|
expected: func() string {
|
||||||
expectedHealthResponse := map[string]any{
|
expectedHealthResponse := SimpleResponse{
|
||||||
"status": 200,
|
Status: 200,
|
||||||
"message": "Healthy",
|
Message: "Healthy",
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(expectedHealthResponse)
|
bytes, err := json.Marshal(expectedHealthResponse)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func NewDefaultConfiguration(runtimeEnv RuntimeEnv) *Config {
|
|||||||
Server: ServerConfig{
|
Server: ServerConfig{
|
||||||
Port: 3000,
|
Port: 3000,
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
|
ScalarEnabled: true,
|
||||||
},
|
},
|
||||||
Auth: AuthConfig{
|
Auth: AuthConfig{
|
||||||
SubdomainsEnabled: true,
|
SubdomainsEnabled: true,
|
||||||
@@ -137,6 +138,7 @@ type ServerConfig struct {
|
|||||||
Port int `description:"The port on which the server listens." yaml:"port,omitempty"`
|
Port int `description:"The port on which the server listens." yaml:"port,omitempty"`
|
||||||
Address string `description:"The address on which the server listens." yaml:"address,omitempty"`
|
Address string `description:"The address on which the server listens." yaml:"address,omitempty"`
|
||||||
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath,omitempty"`
|
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath,omitempty"`
|
||||||
|
ScalarEnabled bool `description:"Enable API docs with Scalar under /scalar." yaml:"scalarEnabled,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthConfig struct {
|
type AuthConfig struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user