GithubHelp home page GithubHelp logo

fib_api's Issues

fibonacciの仕様修正

1,1,2,3....となるような数列がフィボナッチ数として与えらる。

また
GET /fibonacci?n=99
のリクエストが行われた時のときレスポンス例が

{
    "result":218922995834555169026
}

だったため、これに合うような仕様に変更する。

utilの作成

フィボナッチの計算をするだけ
handlerとvalidationで入力ミスがある場合は勝手に弾かれるので、handlerから呼び出されるutilのcalculate.goとかではhandlerからわたされてくるctx.Doneの処理に気をつけながら現状はフィボナッチを計算するだけでいいはず

validationを作成

validationディレクトリを作る
go-playground/validator(https://github.com/go-playground/validator)](https://github.com/go-playground/validator) を使用する

  • init関数内
    • カスタムvalidationを作成
    • validationのメッセージを作成
  • errosディレクトリを作成
    • validation用の標準ライブラリのerrorインターフェースを満たすvalidateErrorとapiErrの型を作成
      • validatErr
        • nが指定されていない場合
        • nが負の値の場合
      • apiErr
        • jsonからうまく構造体に変換できなかった場合
        • 計算時間が長すぎた場合(ctx.Cancelとかで設定してctx.Doneで感知して呼び出す際のエラー)

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.