Skip to content

Instantly share code, notes, and snippets.

View ferhaty's full-sized avatar
🔧
Building stuff!

Ferhat Yildiz ferhaty

🔧
Building stuff!
View GitHub Profile
FROM crystallang/crystal:0.27.0 as compiler
RUN mkdir /src
COPY . /src
WORKDIR /src
RUN shards install && crystal build src/PaymentService.cr --static --release --no-debug -o bin/PaymentService
FROM scratch
COPY --from=compiler /src/bin/PaymentService .
EXPOSE 3000
CMD ["./PaymentService"]
require "../src/PaymentRequest"
require "../src/PaymentResult"
class PaymentExecutionService
def pay(request : PaymentRequest)
# Perform Magic
# ....
paymentResult = PaymentResult.new
# Transaction limit of < 2500
require "kemal"
require "../src/PaymentExecutionService"
get "/pay" do |request|
paymentAmount = request.params.query["amount"].to_f
paymentService = PaymentExecutionService.new()
paymentRequest = PaymentRequest.new(paymentAmount)
paymentResult = paymentService.pay(paymentRequest)
paymentSuccessful = paymentResult.successful
require "http/server"
server = HTTP::Server.new do |context|
context.response.content_type = "text/plain"
context.response.print "Hello world! The time is #{Time.now}"
end
address = server.bind_tcp 8080
puts "Listening on http://#{address}"
server.listen

Keybase proof

I hereby claim:

  • I am ferhaty on github.
  • I am ferhaty (https://keybase.io/ferhaty) on keybase.
  • I have a public key ASArBWEh1G9i-iZ9acaHk3_mpZ3IUHerbon-vGm2zApn4go

To claim this, I am signing this object: