Coder Social home page Coder Social logo

gohttpcliant's Introduction

go言語でHTTPクライアントをつくる

Alexaに喋らせる用の JSONを返すAPIのローカルでのテストツールとして使用したい。

作る予定の機能

  • GETリクエストするだけ
  • POSTできる
  • ファイルに指定した内容をPOSTできる
  • Alexa仕様のリクエストボディをPOSTできる
  • 引数でリクエストタイプを指定できる
  • リクエストボディに実行時日時でタイムスタンプを設定する
  • Alexaのリクエスト仕様に沿ったリクエストの送信

    • リクエストの種類を選べる(Launch,Intent,SessionEnded)
    • タイムスタンプを自動で現在時刻を設定
    • レスポンスのSessionAttributeの内容を 次のリクエストに自動で設定
  • APIのテスト用機能

    • レスポンスがAlexaのレスポンス仕様を満たすか検証する
    • 一連の会話シナリオを設定してテスト可能

ローカルで動かす

◆ JSONサーバーの用意

nodeのjson-serverを導入

$ npm install -g json-server

応答用jsonファイルの作成

{
  "id": 1,
  "name": "The Godfather",
  "director": "Francis Ford Coppola",
  "rating": 9.1
},
{
  "id": 2,
  "name": "Casablanca",
  "director": "Michael Curtiz",
  "rating": 8.8
}

立ち上げ

$ json-server --watch db.json

  \{^_^}/ hi!

  Loading db.json
  Done

◆ httpCliantの実行

go run httpCliant.go

gohttpcliant's People

Contributors

yusukemisa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.