Skip to content

Instantly share code, notes, and snippets.

View JacopoMangiavacchi's full-sized avatar

Jacopo Mangiavacchi JacopoMangiavacchi

View GitHub Profile
@JacopoMangiavacchi
JacopoMangiavacchi / main.swift
Last active October 31, 2017 00:20
Swift - Kitura Rest Test : <- Post <- Request <- Get
import Foundation
import Kitura
import KituraContracts
import KituraKit
struct Language : Codable {
var language: String
}
struct Request : Codable {
@JacopoMangiavacchi
JacopoMangiavacchi / main.go
Created October 23, 2017 17:18
Go - Gorilla Mux Rest Test : <- Post <- Request <- Get
package main
import (
"encoding/json"
"log"
"net/http"
"io"
"io/ioutil"
"github.com/gorilla/mux"
@JacopoMangiavacchi
JacopoMangiavacchi / Program.cs
Created October 23, 2017 17:19
C# - .Net Core Rest Test : <- Post <- Request <- Get
using System;
using System.IO;
using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Routing;
using Newtonsoft.Json;
using System.Net.Http;
@JacopoMangiavacchi
JacopoMangiavacchi / Application.java
Created October 23, 2017 17:20
Java - Spring Rest Test : <- Post <- Request <- Get
package javatest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.client.RestTemplate;
@JacopoMangiavacchi
JacopoMangiavacchi / Application.kt
Created October 23, 2017 17:21
Kotlin - Spring Rest Test : <- Post <- Request <- Get
package kotlindemo
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.client.RestTemplate
@JacopoMangiavacchi
JacopoMangiavacchi / server.js
Created October 23, 2017 17:22
Javascript - Node.js Express.js Rest Test : <- Post <- Request <- Get
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var request = require('request');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var router = express.Router();
@JacopoMangiavacchi
JacopoMangiavacchi / server.ts
Created October 23, 2017 17:23
TypeScript - Node.js Express.js Rest Test : <- Post <- Request <- Get
import * as express from 'express'
import * as bodyParser from "body-parser"
import * as request from 'request'
class Language {
language: string
constructor (language: string) {
this.language = language
}
@JacopoMangiavacchi
JacopoMangiavacchi / app.py
Created October 23, 2017 17:24
Python - Sanic Rest Test : <- Post <- Request <- Get
from sanic import Sanic, response
import requests
app = Sanic(__name__)
@app.route('/language', methods=['GET'])
async def get_language(request):
return response.json({'language': 'Python'})
@app.route('/request', methods=['POST'])
@JacopoMangiavacchi
JacopoMangiavacchi / Boot.scala
Created October 23, 2017 17:25
Scala - Spray Akka Rest Test : <- Post <- Request <- Get
package scalatest
import akka.actor.{ActorSystem, Props}
import akka.io.IO
import spray.can.Http
import akka.pattern.ask
import akka.util.Timeout
import scala.concurrent.duration._
import akka.actor.Actor
import spray.routing._
import Foundation
extension String {
subscript(value: PartialRangeUpTo<Int>) -> Substring {
get {
return self[..<index(startIndex, offsetBy: value.upperBound)]
}
}
subscript(value: PartialRangeThrough<Int>) -> Substring {