File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -37,16 +37,20 @@ abstract class ApiConnection {
3737 Future <String > post (String route, Map <String , dynamic >? params);
3838}
3939
40+ MapEntry <String , String > authHeader (Auth auth) {
41+ // TODO memoize
42+ final authBytes = utf8.encode ("${auth .email }:${auth .apiKey }" );
43+ return MapEntry ('Authorization' , 'Basic ${base64 .encode (authBytes )}' );
44+ }
45+
4046/// An [ApiConnection] that makes real network requests to a real server.
4147class LiveApiConnection extends ApiConnection {
4248 LiveApiConnection ({required super .auth});
4349
4450 Map <String , String > _headers () {
45- // TODO memoize
46- final authBytes = utf8.encode ("${auth .email }:${auth .apiKey }" );
47- return {
48- 'Authorization' : 'Basic ${base64 .encode (authBytes )}' ,
49- };
51+ final Map <String , String > result = {};
52+ result.addEntries ([authHeader (auth)]);
53+ return result;
5054 }
5155
5256 @override
You can’t perform that action at this time.
0 commit comments