or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

build-time-api.mdconfiguration.mdindex.mdruntime-api.md

configuration.mddocs/

0

# Configuration

1

2

The Quarkus Undertow extension provides both runtime and build-time configuration options for controlling servlet behavior, performance settings, and server configuration.

3

4

## Configuration Import

5

6

Configuration is handled through Quarkus configuration system:

7

8

```java

9

import io.quarkus.undertow.runtime.ServletRuntimeConfig;

10

import io.quarkus.undertow.deployment.ServletConfig;

11

import io.smallrye.config.ConfigMapping;

12

```

13

14

## Runtime Configuration

15

16

Runtime configuration properties affect the behavior during application execution and can be modified at runtime.

17

18

### ServletRuntimeConfig

19

20

Runtime configuration interface for servlet settings.

21

22

```java { .api }

23

@ConfigMapping(prefix = "quarkus.servlet")

24

public interface ServletRuntimeConfig {

25

/**

26

* Buffer size for servlet operations

27

* Configuration property: quarkus.servlet.buffer-size

28

*/

29

Optional<MemorySize> bufferSize();

30

31

/**

32

* Whether to use direct buffers

33

* Configuration property: quarkus.servlet.direct-buffers

34

*/

35

Optional<Boolean> directBuffers();

36

37

/**

38

* Maximum number of HTTP request parameters

39

* Configuration property: quarkus.servlet.max-parameters

40

* Default value: 1000

41

*/

42

@WithDefault("1000")

43

int maxParameters();

44

}

45

```

46

47

### Runtime Configuration Properties

48

49

| Property | Type | Default | Description |

50

|----------|------|---------|-------------|

51

| `quarkus.servlet.buffer-size` | `MemorySize` | - | Buffer size for servlet operations (e.g., "8K", "1M") |

52

| `quarkus.servlet.direct-buffers` | `boolean` | - | Whether to use direct buffers for improved performance |

53

| `quarkus.servlet.max-parameters` | `int` | `1000` | Maximum number of HTTP request parameters |

54

55

#### Usage Example

56

57

```properties

58

# application.properties

59

quarkus.servlet.buffer-size=16K

60

quarkus.servlet.direct-buffers=true

61

quarkus.servlet.max-parameters=2000

62

```

63

64

## Build-time Configuration

65

66

Build-time configuration properties are resolved during application build and cannot be changed at runtime.

67

68

### ServletConfig

69

70

Build-time configuration interface for servlet settings.

71

72

```java { .api }

73

@ConfigMapping(prefix = "quarkus.servlet")

74

public interface ServletConfig {

75

/**

76

* Context path for servlet content

77

* Configuration property: quarkus.servlet.context-path

78

*/

79

Optional<String> contextPath();

80

81

/**

82

* Default charset for requests and responses

83

* Configuration property: quarkus.servlet.default-charset

84

* Default value: UTF-8

85

*/

86

@WithDefault("UTF-8")

87

String defaultCharset();

88

}

89

```

90

91

### ServletConfig.ContextPathConverter

92

93

Converter for processing context path values.

94

95

```java { .api }

96

public static class ContextPathConverter implements Converter<String> {

97

/**

98

* Convert and validate context path value

99

*/

100

public String convert(String value) throws IllegalArgumentException;

101

}

102

```

103

104

### Build-time Configuration Properties

105

106

| Property | Type | Default | Description |

107

|----------|------|---------|-------------|

108

| `quarkus.servlet.context-path` | `String` | - | Context path for servlet content (e.g., "/api", "/webapp") |

109

| `quarkus.servlet.default-charset` | `String` | `UTF-8` | Default charset for HTTP requests and responses |

110

111

#### Usage Example

112

113

```properties

114

# application.properties

115

quarkus.servlet.context-path=/api

116

quarkus.servlet.default-charset=UTF-8

117

```

118

119

## Advanced Configuration

120

121

### Performance Tuning

122

123

For high-throughput applications, consider these configuration optimizations:

124

125

```properties

126

# Enable direct buffers for better performance

127

quarkus.servlet.direct-buffers=true

128

129

# Increase buffer size for large requests

130

quarkus.servlet.buffer-size=32K

131

132

# Adjust max parameters for complex forms

133

quarkus.servlet.max-parameters=5000

134

```

135

136

### Development Configuration

137

138

For development environments, you might want different settings:

139

140

```properties

141

# Development profile (application-dev.properties)

142

quarkus.servlet.context-path=/dev

143

quarkus.servlet.max-parameters=500

144

```

145

146

### Production Configuration

147

148

For production deployments:

149

150

```properties

151

# Production profile (application-prod.properties)

152

quarkus.servlet.context-path=/

153

quarkus.servlet.buffer-size=64K

154

quarkus.servlet.direct-buffers=true

155

quarkus.servlet.max-parameters=10000

156

```

157

158

## Configuration Injection

159

160

You can inject configuration into your application components:

161

162

```java

163

@ApplicationScoped

164

public class ServletConfigService {

165

166

@Inject

167

ServletRuntimeConfig runtimeConfig;

168

169

public void logConfiguration() {

170

System.out.println("Max parameters: " + runtimeConfig.maxParameters());

171

runtimeConfig.bufferSize().ifPresent(size ->

172

System.out.println("Buffer size: " + size));

173

runtimeConfig.directBuffers().ifPresent(direct ->

174

System.out.println("Direct buffers: " + direct));

175

}

176

}

177

```

178

179

## Environment-specific Configuration

180

181

Use Quarkus profiles to configure different environments:

182

183

```properties

184

# Base configuration

185

quarkus.servlet.default-charset=UTF-8

186

187

# Development profile

188

%dev.quarkus.servlet.context-path=/dev

189

%dev.quarkus.servlet.max-parameters=100

190

191

# Test profile

192

%test.quarkus.servlet.context-path=/test

193

%test.quarkus.servlet.max-parameters=50

194

195

# Production profile

196

%prod.quarkus.servlet.context-path=/

197

%prod.quarkus.servlet.buffer-size=64K

198

%prod.quarkus.servlet.direct-buffers=true

199

```

200

201

## Types

202

203

```java { .api }

204

// Configuration annotations

205

import io.smallrye.config.ConfigMapping;

206

import io.smallrye.config.WithDefault;

207

import io.smallrye.config.Converter;

208

209

// Memory size type

210

import io.quarkus.runtime.configuration.MemorySize;

211

212

// Standard Java types

213

import java.util.Optional;

214

215

// CDI injection

216

import jakarta.inject.Inject;

217

import jakarta.enterprise.context.ApplicationScoped;

218

```