Skip to content

Commit

Permalink
refactor(http_server): simplify getters
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Mar 21, 2022
1 parent 4b22c02 commit dfd2fd8
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/src/binding_http/http_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import '../scripting_api/exposed_thing.dart';

/// A [ProtocolServer] for the Hypertext Transfer Protocol (HTTP).
class HttpServer extends ProtocolServer {
final String _scheme;
@override
final String scheme;

final int _port;
@override
final int port;

/// Create a new [HttpServer] from an optional [HttpConfig].
HttpServer(HttpConfig? _httpConfig)
// TODO(JKRhb): Check if the scheme should be determined differently.
: _scheme = _httpConfig?.secure ?? false ? "https" : "http",
_port = _portFromConfig(_httpConfig);
: scheme = _httpConfig?.secure ?? false ? "https" : "http",
port = _portFromConfig(_httpConfig);

static int _portFromConfig(HttpConfig? httpConfig) {
final secure = httpConfig?.secure ?? false;
Expand All @@ -34,12 +36,6 @@ class HttpServer extends ProtocolServer {
throw UnimplementedError();
}

@override
int get port => _port;

@override
String get scheme => _scheme;

@override
Future<void> start(Map<String, Map<String, Credentials>> credentials) async {}

Expand Down

0 comments on commit dfd2fd8

Please sign in to comment.