jaguar_dev_proxy 0.0.2 jaguar_dev_proxy: ^0.0.2 copied to clipboard
Jaguar reverse proxy implementation for dev
example/jaguar_dev_proxy_example.dart
// Copyright (c) 2017, teja. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:jaguar/jaguar.dart';
import 'package:jaguar/interceptors.dart';
import 'package:jaguar_dev_proxy/jaguar_dev_proxy.dart';
import 'package:jaguar_reflect/jaguar_reflect.dart';
@Api()
class ExampleApi {
@Get(path: '/api/user')
@WrapEncodeMapToJson()
Map getUser() => {
'name': 'teja',
};
@Get(path: '/client/version')
String getVersion() => '0.1';
}
main() async {
final api = new JaguarReflected(new ExampleApi());
// Proxy all html client requests to pub server
final proxy = new PrefixedProxyServer(
'/client', 'http://localhost:63342/jaguar_dev_proxy/web/');
Configuration conf = new Configuration(address: 'localhost', port: 8085);
conf.addApi(proxy);
conf.addApi(api);
await serve(conf);
}