Skip to content

Commit

Permalink
Merge pull request #115 from bmf-san/feature/use-export-test-pkg
Browse files Browse the repository at this point in the history
Use export test pkg
  • Loading branch information
bmf-san authored Oct 1, 2023
2 parents 4c1ce5b + 0ee8fb4 commit ea7a860
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [デフォルトOPTIONSハンドラー](#デフォルトoptionsハンドラー)
- [ベンチマークテスト](#ベンチマークテスト)
- [設計](#設計)
- [Wiki](#wiki)
- [コントリビューション](#コントリビューション)
- [スポンサー](#スポンサー)
- [ライセンス](#ライセンス)
Expand Down Expand Up @@ -64,7 +65,7 @@ go get -u github.com/bmf-san/goblin
#
サンプルの実装を用意しています。

[_examples](https://github.com/bmf-san/goblin/blob/master/_examples)をご参照ください。
[example_goblin_test.go](https://github.com/bmf-san/goblin/blob/master/example_goblin_test.go)をご参照ください。

# 使い方
## メソッドベースのルーティング
Expand Down Expand Up @@ -335,6 +336,9 @@ HTTPメソッドごとに木を構築するようになっています。

改善のアイデアがあればぜひ教えてください!

# Wiki
参考資料の一覧は[wiki](https://github.com/bmf-san/goblin/wiki)に記載しています。

# コントリビューション
IssueやPull Requestはいつでもお待ちしています。

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This logo was created by [gopherize.me](https://gopherize.me/gopher/d654ddf2b81c
- [Default OPTIONS handler](#default-options-handler)
- [Benchmark tests](#benchmark-tests)
- [Design](#design)
- [Wiki](#wiki)
- [Contribution](#contribution)
- [Sponsor](#sponsor)
- [Stargazers](#stargazers)
Expand Down Expand Up @@ -66,7 +67,7 @@ go get -u github.com/bmf-san/goblin
# Example
A sample implementation is available.

Please refer to [_examples](https://github.com/bmf-san/goblin/blob/master/_examples).
Please refer to [example_goblin_test.go](https://github.com/bmf-san/goblin/blob/master/example_goblin_test.go).

# Usage
## Method based routing
Expand Down
11 changes: 7 additions & 4 deletions _examples/main.go → example_goblin_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package main
package goblin_test

import (
"log"
"net/http"

goblin "github.com/bmf-san/goblin"
"github.com/bmf-san/goblin"
)

func CORS(next http.Handler) http.Handler {
Expand Down Expand Up @@ -34,7 +35,7 @@ func BazHandler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
}

func main() {
func ExampleListenAndServe() {
r := goblin.NewRouter()

r.Methods(http.MethodGet).Handler(`/`, RootHandler())
Expand All @@ -44,5 +45,7 @@ func main() {
r.Methods(http.MethodPost).Use(CORS).Handler(`/foo/:name`, FooNameHandler())
r.Methods(http.MethodGet).Handler(`/baz`, BazHandler())

http.ListenAndServe(":9999", r)
if err := http.ListenAndServe(":9999", r); err != nil {
log.Fatal(err)
}
}

0 comments on commit ea7a860

Please sign in to comment.