public void Setup()
        {
            _formatters = new UrlFormatterCollection();

            var formatter = new UrlFormatter();

            formatter.FromUrl("https://assets.com:9110/v1");

            _formatters.Register("assets", formatter);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an HttpService.
        ///
        /// TODO: This class enforces a json contenttype, but accepts any
        /// TODO: ISerializer.
        /// </summary>
        /// <param name="serializer"></param>
        /// <param name="bootstrapper"></param>
        /// <param name="urls"></param>
        public HttpService(
            ISerializer serializer,
            IBootstrapper bootstrapper,
            UrlFormatterCollection urls)
        {
            _serializer   = serializer;
            _bootstrapper = bootstrapper;

            Services  = new HttpServiceManager(urls);
            TimeoutMs = 10000;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an HttpService.
        ///
        /// TODO: This class enforces a json contenttype, but accepts any
        /// TODO: ISerializer.
        /// </summary>
        /// <param name="serializer"></param>
        /// <param name="bootstrapper"></param>
        /// <param name="urls"></param>
        public HttpService(
            ISerializer serializer,
            IBootstrapper bootstrapper,
            UrlFormatterCollection urls)
        {
            _serializer   = serializer;
            _bootstrapper = bootstrapper;

            Urls    = urls;
            Headers = new Dictionary <string, string>();
        }
Exemplo n.º 4
0
        public void Reverse()
        {
            const string TRELLIS_URL   = "https://cloud.enklu.com:10001/v1/";
            const string STARGAZER_URL = "https://cloud.enklu.com:9973/v1/";
            const string GOOGLE_URL    = "http://www.google.com/v3/";

            var formatters = new UrlFormatterCollection();

            var trellisFormatter   = FormatterFor(TRELLIS_URL);
            var stargazerFormatter = FormatterFor(STARGAZER_URL);
            var googleFormatter    = FormatterFor(GOOGLE_URL);

            // Register formatters
            formatters.Register("trellis", trellisFormatter);
            formatters.Register("stargazer", stargazerFormatter);
            formatters.Register("google", googleFormatter);

            // Resolve names from specific URLs
            Assert.AreEqual("stargazer", formatters.FormatterName($"{STARGAZER_URL}users/13423-abcdsa-53214/snaps?type=still"));
            Assert.AreEqual("trellis", formatters.FormatterName($"{TRELLIS_URL}/foo/man/chu"));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new <see cref="HttpServiceManager"/> instance
 /// </summary>
 public HttpServiceManager(UrlFormatterCollection urls)
 {
     Urls    = urls;
     Headers = new HttpHeaders();
 }