{"id":37184412,"url":"https://github.com/koori69/adventurer","last_synced_at":"2026-01-14T21:18:26.939Z","repository":{"id":57524942,"uuid":"165262642","full_name":"koori69/adventurer","owner":"koori69","description":"Go语言的路由器框架，支持URL正则匹配，API预处理等功能","archived":false,"fork":false,"pushed_at":"2020-04-14T05:58:38.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T17:31:26.375Z","etag":null,"topics":["go","router","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koori69.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-11T15:08:15.000Z","updated_at":"2020-04-09T12:59:09.000Z","dependencies_parsed_at":"2022-08-26T03:31:59.076Z","dependency_job_id":null,"html_url":"https://github.com/koori69/adventurer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/koori69/adventurer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koori69%2Fadventurer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koori69%2Fadventurer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koori69%2Fadventurer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koori69%2Fadventurer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koori69","download_url":"https://codeload.github.com/koori69/adventurer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koori69%2Fadventurer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","router","yaml"],"created_at":"2026-01-14T21:18:26.188Z","updated_at":"2026-01-14T21:18:26.925Z","avatar_url":"https://github.com/koori69.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adventurer\n\nGo语言的路由器框架，支持URL正则匹配，API预处理等功能\n\n## Features\n\n- URL支持正则表达式\n- API预处理\n- URL支持指定请求Method\n- 支持跨域\n- 支持自定义错误返回\n\n## Quick Start\n\n### Story\n\n使用yaml存储配置信息。\n\n例：stories.yaml\n\n```yaml\n- url: \"/test/hello\" # 请求的URL\n  method:  # 支持的Method方法，可以多个\n    - \"GET\"\n  handler: \"DemoHandler\"  # 处理struct 对象的handler方法名称，必须大写开头\n  trials: # 预处理定义，map[string][]string类型，和Hook配对使用\n    token:\n      - \"true\"\n    header:\n      - \"true\"\n    permission:\n      - \"ADMIN\"\n```\n\n加载yaml信息\n\n```go\nstories, err := adventurer.LoadStories(\"./stories/stories.yaml\")\nif nil != err {\n    log.Fatalln(err.Error())\n}\n```\n\n### Hook\n\n如果需要对URL进行预处理，需要实现Hook接口。\n\n```go\ntype HeaderHook struct {\n}\n\nfunc NewHeaderHook() adventurer.Hook {\n\treturn \u0026HeaderHook{}\n}\n\nfunc (h *HeaderHook) Fire(prerequisite []string, equipment adventurer.Equipment) (bool, error) {\n\tif nil == prerequisite || len(prerequisite) \u003c 1 {\n\t\treturn false, nil\n\t}\n\tif \"true\" == prerequisite[0] {\n\t\tif \"\" == equipment.Header.Get(\"device\") {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn true, nil\n}\n```\n\n### 跨域\n\n```go\nadventurer.SetCros(true)\n```\n\n\n\n### Demo\n\n```go\nfunc main() {\n\tlog.SetFlags(log.LstdFlags | log.Lshortfile)\n\tstories, err := adventurer.LoadStories(\"./stories/stories.yaml\")\n\tif nil != err {\n\t\tlog.Fatalln(err.Error())\n\t}\n\thook := make(adventurer.StoryHook, 0)\n\thook[\"header\"] = NewHeaderHook()\n\ta, err := adventurer.NewAdventurer(Demo{}, stories,\n\t\tadventurer.NewProfile(\"/demo/about\", \"0.0.1\", \"1.11.2\", \"\", \"test\"),\n\t\t\u0026hook)\n\tif nil != err {\n\t\tlog.Fatalln(err.Error())\n\t}\n\thttp.HandleFunc(\"/\", a.Explore)\n\tlog.Fatal(http.ListenAndServe(fmt.Sprintf(\":%d\", 2111), nil))\n}\n\n// Demo demo\ntype Demo struct {\n}\n\n// DemoHandler demo handler\nfunc (d *Demo) DemoHandler(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Hello\"))\n}\n\ntype HeaderHook struct {\n}\n\nfunc NewHeaderHook() adventurer.Hook {\n\treturn \u0026HeaderHook{}\n}\n\nfunc (h *HeaderHook) Fire(prerequisite []string, equipment adventurer.Equipment) (bool, error) {\n\tif nil == prerequisite || len(prerequisite) \u003c 1 {\n\t\treturn false, nil\n\t}\n\tif \"true\" == prerequisite[0] {\n\t\tif \"\" == equipment.Header.Get(\"device\") {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn true, nil\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoori69%2Fadventurer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoori69%2Fadventurer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoori69%2Fadventurer/lists"}