This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Thrift | |
import ThriftSwiftNio | |
class TestServiceHandler : TestService { | |
func Hello(HelloString: String) throws -> String { | |
return "Hello " + HelloString | |
} | |
func GetSampleStruct(key: Int32, value: String) throws -> SampleStruct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Thrift | |
do { | |
let serviceURL: URL = URL(string: "http://localhost:9090")! | |
let session: URLSession = URLSession(configuration: .default) | |
let transport: THTTPSessionTransport = THTTPSessionTransport.Factory(session: session, url: serviceURL).newTransport() | |
let proto = TBinaryProtocol(on: transport) | |
let client = TestServiceClient(inoutProtocol: proto) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SampleStruct | |
{ | |
1: i32 key | |
2: string value | |
} | |
service TestService | |
{ | |
string Hello(1:string HelloString), | |
SampleStruct GetSampleStruct(1: i32 key, 2:string value), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct User : Codable { | |
let firstName: String | |
let lastName: String | |
let id: Int | |
} | |
let users = [User(firstName: "John", lastName: "Doe", id: 1), | |
User(firstName: "Jane", lastName: "Doe", id: 2)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Array { | |
mutating func randomize() { | |
for i in 0..<self.count { | |
let r = Int.random(in: 0..<Int(self.count - i)) | |
(self[i], self[i+r]) = (self[i+r], self[i]) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension String { | |
subscript(value: PartialRangeUpTo<Int>) -> Substring { | |
get { | |
return self[..<index(startIndex, offsetBy: value.upperBound)] | |
} | |
} | |
subscript(value: PartialRangeThrough<Int>) -> Substring { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |