Пример #1
0
        public ApiModule()
        {
            var star = new StartWarsDataAgents();
            var http = new Http.HttpClient();

            Get("/", args => JsonConvert.SerializeObject("Hello StarWars"));
            Get("/api/people/{Id}", args => JsonConvert.SerializeObject(star.GetFromPeople(args.Id)));
        }
        public ApiModule()
        {
            var marvel = new MarvelDataAgents();
            var http   = new Http.HttpClient();

            Get("/", args => JsonConvert.SerializeObject("Hello Marvel"));
            Get("/api/Personagem/{Nome}", args => JsonConvert.SerializeObject(marvel.GetFromPerson(args.Nome)));
            Get("/api/Personagem/paginas/{Qtd}", args => JsonConvert.SerializeObject(marvel.GetFromMagazine(args.Qtd)));
        }
Пример #3
0
 /// <summary>
 /// Send and recieve string message.
 /// </summary>
 /// <param name="requestUri">The request uri to upload to.</param>
 /// <param name="message">The received message</param>
 /// <returns>The response message</returns>
 public string MessageString(string requestUri, string message)
 {
     try
     {
         Nequeo.Net.Http.HttpClient http = new Http.HttpClient();
         http.Connection = _connection;
         return(http.UploadString(requestUri, message));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
 /// <summary>
 /// Send and recieve byte message.
 /// </summary>
 /// <param name="requestUri">The request uri to upload to.</param>
 /// <param name="message">The received message</param>
 /// <returns>The response message</returns>
 public byte[] MessageByte(string requestUri, byte[] message)
 {
     try
     {
         Nequeo.Net.Http.HttpClient http = new Http.HttpClient();
         http.Connection = _connection;
         return(Encoding.Default.GetBytes(http.UploadString(requestUri, Encoding.Default.GetString(message))));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #5
0
 /// <summary>
 /// Downloads a request uri to a local file.
 /// </summary>
 /// <param name="requestUri">The request uri to download.</param>
 /// <param name="destinationFile">The local destination file to copy the data to.</param>
 public void DownloadFile(string requestUri, string destinationFile)
 {
     Nequeo.Net.Http.HttpClient http = new Http.HttpClient();
     http.Connection = _connection;
     http.DownloadFile(requestUri, destinationFile);
 }
Пример #6
0
 /// <summary>
 /// Uploads data to the request uri.
 /// </summary>
 /// <param name="requestUri">The request uri to upload to.</param>
 /// <param name="data">The data to upload.</param>
 /// <param name="method">The HTTP method used to send the file to the resource. If null, the default is POST for http.</param>
 /// <returns>A System.String containing the response sent by the server.</returns>
 public string UploadString(string requestUri, string data, string method)
 {
     Nequeo.Net.Http.HttpClient http = new Http.HttpClient();
     http.Connection = _connection;
     return(http.UploadString(requestUri, data, method));
 }
Пример #7
0
 /// <summary>
 /// Upload a local file to the request uri.
 /// </summary>
 /// <param name="requestUri">The request uri to upload to.</param>
 /// <param name="sourceFile">The local source file to upload data from.</param>
 /// <param name="method">The HTTP method used to send the file to the resource. If null, the default is POST for http.</param>
 /// <returns>A System.Byte array containing the body of the response from the resource.</returns>
 public byte[] UploadFile(string requestUri, string sourceFile, string method)
 {
     Nequeo.Net.Http.HttpClient http = new Http.HttpClient();
     http.Connection = _connection;
     return(http.UploadFile(requestUri, sourceFile, method));
 }
Пример #8
0
 /// <summary>
 /// Downloads data from the request uri.
 /// </summary>
 /// <param name="requestUri">The request uri to download.</param>
 /// <returns>The returned request uri content.</returns>
 public string DownloadString(string requestUri)
 {
     Nequeo.Net.Http.HttpClient http = new Http.HttpClient();
     http.Connection = _connection;
     return(http.DownloadString(requestUri));
 }
 public BuiltWithRestClient(string apiKey, Http.HttpClient client = null)
 {
     ApiKey     = apiKey;
     HttpClient = client ?? new Http.BasicHttpClient( );
 }