Founder at MachineBox.io — Gopher, developer, speaker, author — BitBar app https://getbitbar.com — Author of Go Programming Blueprints
5日目担当の@cubicdaiyaです。先月末のGoConではGoのカンファレンスなのにほぼnginxをビルドする話しかしてなかったので今日はちゃんとGoの話をします。 Goで書くサーバプログラム Goではサーバプログラムを書くためのユーティリティが豊富に揃ってる上に、ゴルーチンやチャネルを利用することで高いパフォーマンスが要求される環境でも十分な性能を発揮することができます。いつだったか「あれはHTTPサーバ書くための言語ですよ」なんて話をとあるエンジニアから聞いたことがあるくらいです。 例えば「Hello, World!」を返すだけのHTTPサーバであれば標準ライブラリのnet/httpを利用することで以下のように書くことが出来ます。 package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter,
WebアプリケーションのHTTPレベルでの振る舞いに対してテストを記述するとき、皆さんはどのような考えを持ってテストコードを記述しているでしょうか。この投稿では、この手のrequest-specと呼ばれるテストについて考えながら、テストを書くときの幾つかの方針と、RSpec::RequestDescriberを利用してテストコードを簡略化する方法を紹介します。 request-specとは request-specという、HTTPにおけるリクエストとレスポンスの組み合わせを、言わばブラックボックスとして扱うテスト形式の呼び名があります。リクエストを入力、レスポンスを出力として扱い、ある入力に対して期待される出力が返されるかどうかをテストします。rspec-railsの中では、request-specに対して以下の説明が与えられています。 Use request specs to speci
Taking inspiration from the Rails layouts and rendering guide, I thought it'd be a nice idea to build a snippet collection illustrating some common HTTP responses for Go web applications. Sending Headers Only Rendering Plain Text Rendering JSON Rendering XML Serving a File Rendering a HTML Template Rendering a HTML Template to a String Using Layouts and Nested Templates Sending Headers Only File:
Ruby 上で http を叩いた通信見たい時に、毎回同じ事をやってるので抽象化して http-dump というライブラリを作った。 https://github.com/hotchpotch/http-dump $ gem install http-dump require 'net/http' require 'uri' require 'http-dump' HTTPDump.dump { Net::HTTP.get(URI('http://example.com')) } と http でやりとりしてるコードを block で囲むと、以下のように出力される。 > GET http://example.com/ with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=
接続先のURLは、HainekoがLISTENしているアドレスの/submitです。 $ cp eg/email-01.json /tmp/1.eml ⏎ $ vi /tmp/1.eml ⏎ $ curl -X POST -H 'Content-Type: application/json' -d '@/tmp/1.eml' 'http://127.0.0.1:2794/submit' | jq -M . ⏎ % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 892 100 508 100 384 253 191 0:00:02 0:00:02 --:--:-- 253 { "smtp.remoteport": 51762, "smt
In this post I'm going to talk about using port 80 and 443 for web development on a Mac running 1 or more virtual machines under Vagrant. Why use port 80 and port 443? Port 80 is the standard port for HTTP and 443 is the standard port for HTTPS. While other ports can be used, they're non-standard, and some (if not most) webapps make assumptions about those port numbers. You can really get burned o
RubyやRailsで外部APIを利用するソフトウェアを開発しているときに、テストで実際に何度もAPIに問い合わせにをしていたら、遅くて話になりません。ましてや、外部APIがメンテナンスなんてことになったら、開発が止まってしまいます。 そこで、webmockなどを利用して、HTTPリクエストやレスポンスのmockを作成することが望ましいです。 vcrを組み合わせて利用すれば、初回だけ実際にHTTPリクエストとレスポンスを記録して、2回目以降は記録したデータからmockとしてデータを返すように簡単にできます。 webmockとvcrのインストール方法Gemfileに以下のように記述する group :development, :test do gem 'webmock' gem 'vcr' endgemをインストールする $ bundletest/test_helper.rbにVCRに関する
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く