├── .deepsource.toml ├── .fossa.yml ├── .gitattributes ├── .github ├── CODEOWNERS ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml ├── scripts │ └── setup_examples_test.bash └── workflows │ ├── ci.yml │ └── codeql-analysis.yml ├── .gitignore ├── AUTHORS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── FAQ.md ├── HISTORY.md ├── LICENSE ├── NOTICE ├── README.md ├── README_AR.md ├── README_ES.md ├── README_FA.md ├── README_FR.md ├── README_GR.md ├── README_JA.md ├── README_KO.md ├── README_PT_BR.md ├── README_RU.md ├── README_VN.md ├── README_ZH.md ├── README_ZH_HANS.md ├── README_ZH_HANT.md ├── SECURITY.md ├── VERSION ├── _benchmarks ├── README.md └── view │ ├── README.md │ ├── ace │ ├── main.go │ └── views │ │ ├── index.ace │ │ ├── layouts │ │ └── main.ace │ │ └── partials │ │ └── footer.ace │ ├── blocks │ ├── main.go │ └── views │ │ ├── index.html │ │ ├── layouts │ │ └── main.html │ │ └── partials │ │ └── footer.html │ ├── chart.png │ ├── django │ ├── main.go │ └── views │ │ ├── index.html │ │ ├── layouts │ │ └── main.html │ │ └── partials │ │ └── footer.html │ ├── handlebars │ ├── main.go │ └── views │ │ ├── index.html │ │ ├── layouts │ │ └── main.html │ │ └── partials │ │ └── footer.html │ ├── html │ ├── main.go │ └── views │ │ ├── index.html │ │ ├── layouts │ │ └── main.html │ │ └── partials │ │ └── footer.html │ ├── jet │ ├── main.go │ └── views │ │ ├── index.jet │ │ ├── layouts │ │ └── main.jet │ │ └── partials │ │ └── footer.jet │ ├── pug │ ├── main.go │ └── views │ │ ├── index.pug │ │ ├── layouts │ │ └── main.pug │ │ └── partials │ │ └── footer.pug │ └── tests.yml ├── _examples ├── README.md ├── README_ZH_HANT.md ├── apidoc │ └── swagger │ │ └── README.md ├── auth │ ├── auth │ │ ├── README.md │ │ ├── auth.yml │ │ ├── main.go │ │ ├── user.go │ │ ├── user_provider.go │ │ └── views │ │ │ ├── layouts │ │ │ └── main.html │ │ │ ├── partials │ │ │ └── footer.html │ │ │ └── signin.html │ ├── basicauth │ │ ├── basic │ │ │ ├── main.go │ │ │ └── main_test.go │ │ ├── database │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── docker-compose.yml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ └── migration │ │ │ │ └── db.sql │ │ ├── users_file_bcrypt │ │ │ ├── main.go │ │ │ └── users.yml │ │ └── users_list │ │ │ └── main.go │ ├── cors │ │ ├── main.go │ │ └── public │ │ │ ├── index.html │ │ │ └── main.js │ ├── goth │ │ ├── main.go │ │ └── templates │ │ │ ├── index.html │ │ │ └── user.html │ ├── hcaptcha │ │ ├── hosts │ │ ├── main.go │ │ └── templates │ │ │ └── register_form.html │ ├── jwt │ │ ├── basic │ │ │ └── main.go │ │ ├── blocklist │ │ │ └── main.go │ │ ├── middleware │ │ │ └── main.go │ │ ├── refresh-token │ │ │ ├── main.go │ │ │ ├── rsa_private_key.pem │ │ │ └── rsa_public_key.pem │ │ └── tutorial │ │ │ ├── README.md │ │ │ ├── api │ │ │ ├── auth.go │ │ │ ├── router.go │ │ │ └── todo.go │ │ │ ├── domain │ │ │ ├── model │ │ │ │ ├── role.go │ │ │ │ ├── todo.go │ │ │ │ └── user.go │ │ │ └── repository │ │ │ │ ├── samples.go │ │ │ │ ├── todo_repository.go │ │ │ │ └── user_repository.go │ │ │ ├── go-client │ │ │ ├── README.md │ │ │ ├── client.go │ │ │ └── main.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ └── util │ │ │ ├── app.go │ │ │ ├── clock.go │ │ │ ├── password.go │ │ │ └── uuid.go │ ├── permissions │ │ └── main.go │ └── recaptcha │ │ ├── custom_form │ │ └── main.go │ │ └── main.go ├── bootstrapper │ ├── bootstrap │ │ └── bootstrapper.go │ ├── folder_structure.png │ ├── go.mod │ ├── go.sum │ ├── main.go │ ├── main_test.go │ ├── middleware │ │ └── identity │ │ │ └── identity.go │ ├── public │ │ └── favicon.ico │ ├── routes │ │ ├── follower.go │ │ ├── following.go │ │ ├── index.go │ │ ├── like.go │ │ └── routes.go │ └── views │ │ ├── index.html │ │ └── shared │ │ ├── error.html │ │ └── layout.html ├── caddy │ ├── Caddyfile │ ├── README.md │ ├── server1 │ │ ├── main.go │ │ └── views │ │ │ ├── index.html │ │ │ └── shared │ │ │ └── layout.html │ └── server2 │ │ └── main.go ├── compression │ ├── client-using-iris │ │ └── main.go │ ├── client │ │ └── main.go │ ├── main.go │ └── main_test.go ├── configuration │ ├── from-configuration-structure │ │ └── main.go │ ├── from-toml-file │ │ ├── configs │ │ │ └── iris.tml │ │ └── main.go │ ├── from-yaml-file │ │ ├── configs │ │ │ └── iris.yml │ │ ├── main.go │ │ └── shared-configuration │ │ │ └── main.go │ ├── functional │ │ └── main.go │ ├── multi-environments │ │ ├── README.md │ │ ├── api │ │ │ ├── configuration.go │ │ │ └── server.go │ │ ├── cmd │ │ │ └── root_command.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ ├── server.dev.yml │ │ └── server.yml │ └── viper │ │ ├── config.yml │ │ ├── config │ │ └── config.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go ├── convert-handlers │ ├── negroni-like │ │ └── main.go │ ├── nethttp │ │ ├── main.go │ │ └── wrapper │ │ │ └── main.go │ └── real-usecase-raven │ │ ├── wrapping-the-router │ │ └── main.go │ │ └── writing-middleware │ │ └── main.go ├── cookies │ ├── basic │ │ ├── main.go │ │ └── main_test.go │ ├── options │ │ ├── main.go │ │ └── main_test.go │ └── securecookie │ │ ├── main.go │ │ └── main_test.go ├── database │ ├── mongodb │ │ ├── .env │ │ ├── 0_create_movie.png │ │ ├── 1_update_movie.png │ │ ├── 2_get_all_movies.png │ │ ├── 3_get_movie.png │ │ ├── 4_delete_movie.png │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── api │ │ │ └── store │ │ │ │ └── movie.go │ │ ├── docker-compose.yml │ │ ├── env │ │ │ └── env.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── httputil │ │ │ └── error.go │ │ ├── main.go │ │ └── store │ │ │ └── movie.go │ ├── mysql │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── api │ │ │ ├── api.go │ │ │ ├── category_handler.go │ │ │ ├── helper.go │ │ │ ├── httperror.go │ │ │ ├── middleware │ │ │ │ └── .gitkeep │ │ │ └── product_handler.go │ │ ├── cache │ │ │ └── groupcache.go │ │ ├── docker-compose.yml │ │ ├── entity │ │ │ ├── category.go │ │ │ └── product.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ ├── migration │ │ │ ├── api_category │ │ │ │ ├── create_category.json │ │ │ │ ├── insert_products_category.json │ │ │ │ ├── update_category.json │ │ │ │ └── update_partial_category.json │ │ │ ├── api_postman.json │ │ │ ├── api_product │ │ │ │ ├── create_product.json │ │ │ │ ├── update_partial_product.json │ │ │ │ └── update_product.json │ │ │ └── db.sql │ │ ├── service │ │ │ ├── category_service.go │ │ │ ├── category_service_test.go │ │ │ └── product_service.go │ │ └── sql │ │ │ ├── mysql.go │ │ │ ├── service.go │ │ │ └── sql.go │ ├── orm │ │ ├── gorm │ │ │ ├── REAMDE.md │ │ │ └── main.go │ │ ├── reform │ │ │ ├── controllers │ │ │ │ └── person_controller.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ ├── models │ │ │ │ ├── person.go │ │ │ │ └── person_reform.go │ │ │ └── postman_collection.json │ │ └── sqlx │ │ │ └── main.go │ └── sqlx │ │ └── main.go ├── dependency-injection │ ├── basic │ │ ├── main.go │ │ └── middleware │ │ │ ├── main.go │ │ │ └── main_test.go │ ├── context-register-dependency │ │ └── main.go │ ├── jwt │ │ ├── contrib │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ └── main.go │ ├── overview │ │ ├── datamodels │ │ │ └── movie.go │ │ ├── datasource │ │ │ └── movies.go │ │ ├── main.go │ │ ├── repositories │ │ │ └── movie_repository.go │ │ ├── services │ │ │ └── movie_service.go │ │ └── web │ │ │ ├── middleware │ │ │ └── basicauth.go │ │ │ ├── routes │ │ │ ├── hello.go │ │ │ └── movies.go │ │ │ └── views │ │ │ └── hello │ │ │ ├── index.html │ │ │ └── name.html │ ├── sessions │ │ ├── main.go │ │ └── routes │ │ │ └── index.go │ └── smart-contract │ │ └── main.go ├── desktop │ ├── blink │ │ └── main.go │ ├── lorca │ │ └── main.go │ └── webview │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go ├── dropzonejs │ ├── README.md │ ├── README_PART2.md │ ├── folder_structure.png │ ├── meta.yml │ ├── no_files.png │ ├── src │ │ ├── main.go │ │ ├── public │ │ │ ├── css │ │ │ │ └── dropzone.css │ │ │ └── js │ │ │ │ └── dropzone.js │ │ └── views │ │ │ └── upload.html │ └── with_files.png ├── file-server │ ├── basic │ │ ├── assets.system │ │ │ ├── css │ │ │ │ └── main.css │ │ │ └── test.txt │ │ ├── assets │ │ │ ├── app2 │ │ │ │ ├── app22 │ │ │ │ │ └── just_a_text_no_index.txt │ │ │ │ ├── app2app3 │ │ │ │ │ └── index.html │ │ │ │ └── index.html │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ └── js │ │ │ │ └── main.js │ │ ├── main.go │ │ └── main_test.go │ ├── embedding-files-into-app-bindata │ │ ├── assets │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── favicon.ico │ │ │ └── js │ │ │ │ └── main.js │ │ ├── bindata.go │ │ ├── main.go │ │ └── main_test.go │ ├── embedding-files-into-app │ │ ├── assets │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── favicon.ico │ │ │ └── js │ │ │ │ └── main.js │ │ ├── main.go │ │ └── main_test.go │ ├── embedding-gzipped-files-into-app-bindata │ │ ├── bindata.go │ │ ├── main.go │ │ └── main_test.go │ ├── favicon │ │ ├── main.go │ │ └── static │ │ │ └── favicons │ │ │ └── favicon.ico │ ├── file-server │ │ ├── main.go │ │ └── views │ │ │ ├── dirlist.html │ │ │ └── upload.html │ ├── http2push-embedded-gzipped │ │ ├── bindata.go │ │ └── main.go │ ├── http2push-embedded │ │ ├── bindata.go │ │ └── main.go │ ├── http2push │ │ ├── assets │ │ │ ├── app2 │ │ │ │ ├── app2app3 │ │ │ │ │ ├── css │ │ │ │ │ │ └── main.css │ │ │ │ │ ├── dirs │ │ │ │ │ │ ├── dir1 │ │ │ │ │ │ │ └── text.txt │ │ │ │ │ │ ├── dir2 │ │ │ │ │ │ │ └── text.txt │ │ │ │ │ │ └── text.txt │ │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ └── mydir │ │ │ │ │ └── text.txt │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ └── js │ │ │ │ └── main.js │ │ ├── main.go │ │ ├── mycert.crt │ │ └── mykey.key │ ├── send-files │ │ ├── files │ │ │ └── first.zip │ │ └── main.go │ ├── single-page-application │ │ ├── basic │ │ │ ├── main.go │ │ │ └── public │ │ │ │ ├── index.html │ │ │ │ └── index.js │ │ ├── embedded-single-page-application-with-other-routes │ │ │ ├── bindata.go │ │ │ ├── main.go │ │ │ └── public │ │ │ │ ├── app.js │ │ │ │ ├── css │ │ │ │ └── main.css │ │ │ │ └── index.html │ │ └── embedded-single-page-application │ │ │ ├── bindata.go │ │ │ ├── data │ │ │ ├── public │ │ │ │ ├── app.js │ │ │ │ ├── app2 │ │ │ │ │ └── index.html │ │ │ │ └── css │ │ │ │ │ └── main.css │ │ │ └── views │ │ │ │ └── index.html │ │ │ ├── main.go │ │ │ └── main_test.go │ ├── spa-vue-router │ │ ├── frontend │ │ │ ├── css │ │ │ │ └── page.css │ │ │ ├── index.html │ │ │ └── js │ │ │ │ └── app.js │ │ └── main.go │ ├── subdomain │ │ ├── assets │ │ │ ├── app2 │ │ │ │ ├── app22 │ │ │ │ │ └── just_a_text_no_index.txt │ │ │ │ ├── app2app3 │ │ │ │ │ └── index.html │ │ │ │ └── index.html │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ └── js │ │ │ │ └── jquery-2.1.1.js │ │ ├── hosts │ │ ├── main.go │ │ └── main_test.go │ ├── upload-file │ │ ├── main.go │ │ ├── templates │ │ │ └── upload_form.html │ │ └── uploads │ │ │ └── .gitkeep │ ├── upload-files │ │ ├── main.go │ │ ├── main_test.go │ │ ├── templates │ │ │ └── upload_form.html │ │ └── uploads │ │ │ └── .gitkeep │ └── webdav │ │ ├── main.go │ │ ├── newdir │ │ └── .gitkeep │ │ └── test.txt ├── graphql │ └── schema-first │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gqlgen.yml │ │ ├── graph │ │ ├── generated.go │ │ ├── model │ │ │ └── models_gen.go │ │ ├── resolver.go │ │ ├── schema.graphqls │ │ └── schema.resolvers.go │ │ ├── server.go │ │ └── tools.go ├── http-client │ └── weatherapi │ │ ├── client │ │ ├── client.go │ │ └── response.go │ │ └── main.go ├── http-server │ ├── README.md │ ├── custom-httpserver │ │ ├── easy-way │ │ │ └── main.go │ │ ├── multi │ │ │ └── main.go │ │ └── std-way │ │ │ └── main.go │ ├── custom-listener │ │ └── main.go │ ├── graceful-shutdown │ │ ├── custom-notifier │ │ │ └── main.go │ │ └── default-notifier │ │ │ └── main.go │ ├── h2c │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go │ ├── http3-quic │ │ ├── go.mod │ │ ├── go.sum │ │ ├── localhost.cert │ │ ├── localhost.key │ │ └── main.go │ ├── iris-configurator-and-host-configurator │ │ └── main.go │ ├── listen-addr-public │ │ └── main.go │ ├── listen-addr │ │ ├── main.go │ │ └── omit-server-errors │ │ │ ├── main.go │ │ │ └── main_test.go │ ├── listen-letsencrypt │ │ └── main.go │ ├── listen-tls │ │ ├── main.go │ │ ├── mycert.crt │ │ └── mykey.key │ ├── listen-unix │ │ └── main.go │ ├── notify-on-shutdown │ │ └── main.go │ ├── socket-sharding │ │ └── main.go │ └── timeout │ │ └── main.go ├── i18n │ ├── basic │ │ ├── hosts │ │ ├── locales │ │ │ ├── el-GR │ │ │ │ ├── locale_el-GR.ini │ │ │ │ ├── locale_multi_first_el-GR.yml │ │ │ │ └── locale_multi_second_el-GR.ini │ │ │ ├── en-US │ │ │ │ ├── locale_en-US.ini │ │ │ │ ├── locale_multi_first_en-US.yml │ │ │ │ └── locale_multi_second_en-US.ini │ │ │ └── zh-CN │ │ │ │ └── locale_zh-CN.ini │ │ ├── main.go │ │ ├── main_test.go │ │ └── views │ │ │ └── index.html │ ├── plurals │ │ ├── locales │ │ │ └── en-US │ │ │ │ ├── 1648.ini │ │ │ │ └── welcome.yml │ │ ├── main.go │ │ └── main_test.go │ ├── template-embedded │ │ ├── embedded │ │ │ └── locales │ │ │ │ ├── el-GR │ │ │ │ ├── other.ini │ │ │ │ └── user.ini │ │ │ │ └── en-US │ │ │ │ ├── other.ini │ │ │ │ └── user.ini │ │ ├── main.go │ │ └── main_test.go │ └── template │ │ ├── locales │ │ ├── el-GR │ │ │ ├── other.ini │ │ │ └── user.ini │ │ └── en-US │ │ │ ├── other.ini │ │ │ └── user.ini │ │ ├── main.go │ │ └── main_test.go ├── kafka-api │ ├── 0_docs.png │ ├── 1_create_topic.png │ ├── 2_list_topics.png │ ├── 3_store_to_topic.png │ ├── 4_retrieve_from_topic_real_time.png │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── go.mod │ ├── go.sum │ ├── main.go │ └── postman_collection.json ├── logging │ ├── file-logger │ │ └── main.go │ ├── json-logger │ │ ├── main.go │ │ └── main_test.go │ ├── request-logger │ │ ├── accesslog-broker │ │ │ └── main.go │ │ ├── accesslog-csv │ │ │ ├── access_log.csv.sample │ │ │ └── main.go │ │ ├── accesslog-formatter │ │ │ └── main.go │ │ ├── accesslog-proxy │ │ │ ├── main.go │ │ │ └── target │ │ │ │ └── main.go │ │ ├── accesslog-simple │ │ │ ├── access.log.sample │ │ │ └── main.go │ │ ├── accesslog-slack │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ └── slack_formatter.go │ │ ├── accesslog-template │ │ │ └── main.go │ │ └── accesslog │ │ │ ├── access.log.sample │ │ │ ├── main.go │ │ │ └── public │ │ │ └── index.html │ └── rollbar │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go ├── monitor │ ├── monitor-middleware │ │ └── main.go │ └── statsviz │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go ├── mvc │ ├── authenticated-controller │ │ ├── main.go │ │ └── main_test.go │ ├── basic │ │ ├── main.go │ │ └── wildcard │ │ │ └── main.go │ ├── error-handler-custom-result │ │ ├── main.go │ │ └── views │ │ │ ├── 404.html │ │ │ └── 500.html │ ├── error-handler-hijack │ │ ├── main.go │ │ └── views │ │ │ ├── 404.html │ │ │ └── 500.html │ ├── error-handler-http │ │ ├── main.go │ │ ├── main_test.go │ │ └── views │ │ │ ├── 404.html │ │ │ ├── 500.html │ │ │ └── unexpected-error.html │ ├── error-handler-preflight │ │ ├── main.go │ │ └── views │ │ │ ├── 404.html │ │ │ └── 500.html │ ├── error-handler │ │ └── main.go │ ├── grpc-compatible-bidirectional-stream │ │ ├── client │ │ │ └── main.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helloworld.proto │ │ ├── helloworld │ │ │ ├── helloworld.pb.go │ │ │ └── helloworld_grpc.pb.go │ │ ├── server.crt │ │ ├── server.key │ │ └── server │ │ │ └── main.go │ ├── grpc-compatible │ │ ├── README.md │ │ ├── grpc-client │ │ │ └── main.go │ │ ├── helloworld │ │ │ ├── README.md │ │ │ ├── helloworld.pb.go │ │ │ └── helloworld.proto │ │ ├── http-client │ │ │ └── main.go │ │ ├── main.go │ │ ├── main_test.go │ │ ├── server.crt │ │ └── server.key │ ├── hello-world │ │ ├── main.go │ │ └── main_test.go │ ├── login-mvc-single-responsibility │ │ ├── folder_structure.png │ │ ├── main.go │ │ ├── public │ │ │ └── css │ │ │ │ └── site.css │ │ ├── user │ │ │ ├── auth.go │ │ │ ├── controller.go │ │ │ ├── datasource.go │ │ │ └── model.go │ │ └── views │ │ │ ├── shared │ │ │ ├── error.html │ │ │ └── layout.html │ │ │ └── user │ │ │ ├── login.html │ │ │ ├── me.html │ │ │ ├── notfound.html │ │ │ └── register.html │ ├── login │ │ ├── datamodels │ │ │ └── user.go │ │ ├── datasource │ │ │ └── users.go │ │ ├── folder_structure.png │ │ ├── main.go │ │ ├── repositories │ │ │ └── user_repository.go │ │ ├── services │ │ │ └── user_service.go │ │ └── web │ │ │ ├── controllers │ │ │ ├── user_controller.go │ │ │ └── users_controller.go │ │ │ ├── middleware │ │ │ └── basicauth.go │ │ │ ├── public │ │ │ └── css │ │ │ │ └── site.css │ │ │ ├── viewmodels │ │ │ └── README.md │ │ │ └── views │ │ │ ├── shared │ │ │ ├── error.html │ │ │ └── layout.html │ │ │ └── user │ │ │ ├── login.html │ │ │ ├── me.html │ │ │ └── register.html │ ├── middleware │ │ ├── main.go │ │ ├── per-method │ │ │ └── main.go │ │ └── without-ctx-next │ │ │ └── main.go │ ├── overview │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── controller │ │ │ └── greet_controller.go │ │ ├── database │ │ │ ├── database.go │ │ │ ├── mysql.go │ │ │ └── sqlite.go │ │ ├── docker-compose.yml │ │ ├── environment │ │ │ └── environment.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ ├── model │ │ │ ├── request.go │ │ │ └── response.go │ │ └── service │ │ │ └── greet_service.go │ ├── regexp │ │ └── main.go │ ├── repository │ │ ├── datamodels │ │ │ ├── README.md │ │ │ └── movie.go │ │ ├── datasource │ │ │ ├── README.md │ │ │ └── movies.go │ │ ├── folder_structure.png │ │ ├── main.go │ │ ├── models │ │ │ └── README.md │ │ ├── repositories │ │ │ ├── README.md │ │ │ └── movie_repository.go │ │ ├── services │ │ │ ├── README.md │ │ │ └── movie_service.go │ │ └── web │ │ │ ├── controllers │ │ │ ├── hello_controller.go │ │ │ └── movie_controller.go │ │ │ ├── middleware │ │ │ └── basicauth.go │ │ │ ├── viewmodels │ │ │ └── README.md │ │ │ └── views │ │ │ └── hello │ │ │ ├── index.html │ │ │ └── name.html │ ├── request-default-values │ │ └── main.go │ ├── session-controller │ │ ├── main.go │ │ └── main_test.go │ ├── singleton │ │ └── main.go │ ├── versioned-controller │ │ ├── main.go │ │ └── main_test.go │ ├── vuejs-todo-mvc │ │ ├── README.md │ │ ├── screen.png │ │ └── src │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── todo │ │ │ ├── item.go │ │ │ └── service.go │ │ │ └── web │ │ │ ├── controllers │ │ │ └── todo_controller.go │ │ │ ├── main.go │ │ │ └── public │ │ │ ├── css │ │ │ └── index │ │ │ ├── index.html │ │ │ └── js │ │ │ ├── app.js │ │ │ └── lib │ │ │ └── .gitkeep │ ├── websocket-auth │ │ ├── auth.yml │ │ ├── browser │ │ │ └── index.html │ │ ├── main.go │ │ ├── user.go │ │ ├── user_provider.go │ │ └── views │ │ │ ├── layouts │ │ │ └── main.html │ │ │ ├── partials │ │ │ └── footer.html │ │ │ └── signin.html │ └── websocket │ │ ├── browser │ │ └── index.html │ │ └── main.go ├── pprof │ └── main.go ├── project │ ├── README.md │ ├── api │ │ ├── configuration.go │ │ ├── router.go │ │ ├── server.go │ │ └── users │ │ │ └── api.go │ ├── cmd │ │ ├── cmd.go │ │ └── help.go │ ├── go.mod │ ├── go.sum │ ├── main.go │ ├── pkg │ │ ├── database │ │ │ └── database.go │ │ └── http │ │ │ └── handlers │ │ │ └── cors.go │ ├── server.yml │ └── user │ │ ├── repository.go │ │ └── user.go ├── recover │ ├── main.go │ └── panic-and-custom-error-handler-with-compression │ │ └── main.go ├── request-body │ ├── form-query-headers-params-decoder │ │ └── main.go │ ├── read-body │ │ ├── main.go │ │ └── main_test.go │ ├── read-custom-per-type │ │ ├── main.go │ │ └── main_test.go │ ├── read-custom-via-unmarshaler │ │ ├── main.go │ │ └── main_test.go │ ├── read-form │ │ ├── checkboxes │ │ │ ├── main.go │ │ │ └── templates │ │ │ │ └── form.html │ │ ├── main.go │ │ └── templates │ │ │ └── form.html │ ├── read-headers │ │ ├── main.go │ │ └── main_test.go │ ├── read-json-stream │ │ └── main.go │ ├── read-json-struct-validation │ │ └── main.go │ ├── read-json │ │ └── main.go │ ├── read-many │ │ └── main.go │ ├── read-msgpack │ │ └── main.go │ ├── read-params │ │ ├── main.go │ │ └── main_test.go │ ├── read-query │ │ └── main.go │ ├── read-url │ │ ├── main.go │ │ └── main_test.go │ ├── read-xml │ │ ├── main.go │ │ └── main_test.go │ └── read-yaml │ │ ├── main.go │ │ └── main_test.go ├── request-ratelimit │ ├── rate-middleware │ │ └── main.go │ └── ulule-limiter │ │ └── main.go ├── request-referrer │ └── main.go ├── response-writer │ ├── cache │ │ ├── client-side │ │ │ └── main.go │ │ └── simple │ │ │ └── main.go │ ├── content-negotiation │ │ ├── main.go │ │ └── main_test.go │ ├── http2push │ │ ├── main.go │ │ ├── mycert.crt │ │ ├── mykey.key │ │ └── public │ │ │ └── main.js │ ├── json-third-party │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go │ ├── protobuf │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ └── protos │ │ │ ├── hello.pb.go │ │ │ └── hello.proto │ ├── sse-third-party-2 │ │ ├── index.html │ │ └── main.go │ ├── sse-third-party │ │ └── main.go │ ├── sse │ │ ├── main.go │ │ └── optional.sse.mini.js.html │ ├── stream-writer │ │ └── main.go │ └── write-rest │ │ └── main.go ├── routing │ ├── basic │ │ ├── .dockerignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── main.go │ │ └── main_test.go │ ├── conditional-chain │ │ ├── main.go │ │ └── main_test.go │ ├── custom-context │ │ └── main.go │ ├── custom-router │ │ └── main.go │ ├── custom-wrapper │ │ ├── main.go │ │ ├── main_test.go │ │ └── public │ │ │ ├── app.js │ │ │ ├── css │ │ │ └── main.css │ │ │ └── index.html │ ├── dynamic-path │ │ ├── at-username │ │ │ └── main.go │ │ ├── main.go │ │ ├── root-wildcard │ │ │ └── main.go │ │ └── same-pattern-different-func │ │ │ ├── main.go │ │ │ ├── main_test.go │ │ │ └── use-global │ │ │ ├── main.go │ │ │ └── main_test.go │ ├── hello-world │ │ └── main.go │ ├── http-errors │ │ ├── main.go │ │ └── reset-body │ │ │ ├── main.go │ │ │ └── main_test.go │ ├── http-wire-errors │ │ ├── main.go │ │ └── service │ │ │ └── main.go │ ├── intelligence │ │ ├── main.go │ │ └── manual │ │ │ └── main.go │ ├── macros │ │ └── main.go │ ├── main.go │ ├── main_test.go │ ├── overview-2 │ │ ├── main.go │ │ └── views │ │ │ └── user │ │ │ ├── create_verification.html │ │ │ └── profile.html │ ├── overview │ │ ├── main.go │ │ └── public │ │ │ ├── assets │ │ │ └── css │ │ │ │ └── main.css │ │ │ └── images │ │ │ └── favicon.ico │ ├── party-controller │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ └── pkg │ │ │ └── weatherapi │ │ │ ├── client.go │ │ │ └── response.go │ ├── remove-handler │ │ ├── main.go │ │ └── main_test.go │ ├── remove-route │ │ └── main.go │ ├── reverse │ │ └── main.go │ ├── rewrite │ │ ├── hosts │ │ ├── main.go │ │ └── redirects.yml │ ├── route-handlers-execution-rules │ │ └── main.go │ ├── route-register-rule │ │ ├── main.go │ │ └── main_test.go │ ├── route-state │ │ └── main.go │ ├── sitemap │ │ ├── main.go │ │ └── main_test.go │ ├── subdomains │ │ ├── http-errors-view │ │ │ ├── main.go │ │ │ ├── main_test.go │ │ │ └── views │ │ │ │ ├── error.html │ │ │ │ ├── index.html │ │ │ │ ├── layouts │ │ │ │ ├── layout.html │ │ │ │ └── test.layout.html │ │ │ │ └── partials │ │ │ │ ├── 404.html │ │ │ │ └── 500.html │ │ ├── multi │ │ │ ├── hosts │ │ │ ├── main.go │ │ │ └── public │ │ │ │ ├── assets │ │ │ │ └── images │ │ │ │ │ └── test.ico │ │ │ │ └── upload_resources │ │ │ │ └── favicon.ico │ │ ├── redirect │ │ │ ├── hosts │ │ │ ├── main.go │ │ │ └── multi-instances │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── main.go │ │ │ │ ├── other │ │ │ │ └── server.go │ │ │ │ └── root │ │ │ │ └── server.go │ │ ├── single │ │ │ ├── hosts │ │ │ └── main.go │ │ ├── wildcard │ │ │ ├── hosts │ │ │ └── main.go │ │ └── www │ │ │ ├── hosts │ │ │ ├── main.go │ │ │ ├── main_test.go │ │ │ └── www-method │ │ │ └── main.go │ ├── versioning │ │ ├── main.go │ │ ├── v1 │ │ │ └── index.html │ │ ├── v2 │ │ │ └── index.html │ │ └── v3 │ │ │ └── index.html │ └── writing-a-middleware │ │ ├── globally │ │ └── main.go │ │ ├── per-route │ │ └── main.go │ │ ├── share-funcs │ │ ├── main.go │ │ └── main_test.go │ │ └── share-services │ │ ├── main.go │ │ └── main_test.go ├── sessions │ ├── basic │ │ └── main.go │ ├── database │ │ ├── badger │ │ │ └── main.go │ │ ├── boltdb │ │ │ └── main.go │ │ └── redis │ │ │ ├── Dockerfile │ │ │ ├── docker-compose.yml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ ├── flash-messages │ │ └── main.go │ ├── overview │ │ ├── example │ │ │ └── example.go │ │ └── main.go │ ├── securecookie │ │ ├── main.go │ │ └── main_test.go │ └── viewdata │ │ ├── main.go │ │ └── views │ │ └── index.html ├── testing │ ├── ginkgotest │ │ ├── ginkgotest_suite_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ └── main_test.go │ └── httptest │ │ ├── main.go │ │ └── main_test.go ├── url-shortener │ ├── README.md │ ├── factory.go │ ├── main.go │ ├── main_test.go │ ├── resources │ │ └── css │ │ │ └── style.css │ ├── store.go │ └── templates │ │ └── index.html ├── view │ ├── context-view-data │ │ ├── main.go │ │ └── templates │ │ │ ├── index.html │ │ │ └── layouts │ │ │ └── layout.html │ ├── context-view-engine │ │ ├── main.go │ │ └── views │ │ │ ├── admin │ │ │ ├── index.html │ │ │ └── layouts │ │ │ │ └── main.html │ │ │ ├── on-fly │ │ │ └── index.html │ │ │ └── public │ │ │ ├── 500.html │ │ │ ├── index.html │ │ │ ├── layouts │ │ │ ├── error.html │ │ │ └── main.html │ │ │ └── partials │ │ │ └── footer.html │ ├── embedding-templates-into-app-bindata │ │ ├── bindata.go │ │ ├── main.go │ │ └── templates │ │ │ ├── layouts │ │ │ ├── layout.html │ │ │ └── mylayout.html │ │ │ ├── page1.html │ │ │ └── partials │ │ │ └── page1_partial1.html │ ├── embedding-templates-into-app │ │ ├── embedded │ │ │ └── templates │ │ │ │ ├── layouts │ │ │ │ ├── layout.html │ │ │ │ └── mylayout.html │ │ │ │ ├── page1.html │ │ │ │ └── partials │ │ │ │ └── page1_partial1.html │ │ └── main.go │ ├── fallback │ │ ├── main.go │ │ └── view │ │ │ └── fallback.html │ ├── herotemplate │ │ ├── README.md │ │ ├── app.go │ │ └── template │ │ │ ├── index.html │ │ │ ├── index.html.go │ │ │ ├── user.html │ │ │ ├── user.html.go │ │ │ ├── userlist.html │ │ │ ├── userlist.html.go │ │ │ ├── userlistwriter.html │ │ │ └── userlistwriter.html.go │ ├── layout │ │ ├── ace │ │ │ ├── main.go │ │ │ └── views │ │ │ │ ├── index.ace │ │ │ │ ├── layouts │ │ │ │ └── main.ace │ │ │ │ └── partials │ │ │ │ └── footer.ace │ │ ├── blocks │ │ │ ├── main.go │ │ │ └── views │ │ │ │ ├── index.html │ │ │ │ ├── layouts │ │ │ │ └── main.html │ │ │ │ └── partials │ │ │ │ └── footer.html │ │ ├── django │ │ │ ├── main.go │ │ │ └── views │ │ │ │ ├── index.html │ │ │ │ ├── layouts │ │ │ │ └── main.html │ │ │ │ └── partials │ │ │ │ └── footer.html │ │ ├── handlebars │ │ │ ├── main.go │ │ │ └── views │ │ │ │ ├── index.html │ │ │ │ ├── layouts │ │ │ │ └── main.html │ │ │ │ └── partials │ │ │ │ └── footer.html │ │ ├── html │ │ │ ├── main.go │ │ │ └── views │ │ │ │ ├── index.html │ │ │ │ ├── layouts │ │ │ │ └── main.html │ │ │ │ └── partials │ │ │ │ └── footer.html │ │ ├── jet │ │ │ ├── main.go │ │ │ └── views │ │ │ │ ├── index.jet │ │ │ │ ├── layouts │ │ │ │ └── main.jet │ │ │ │ └── partials │ │ │ │ └── footer.jet │ │ └── pug │ │ │ ├── main.go │ │ │ └── views │ │ │ ├── index.pug │ │ │ ├── layouts │ │ │ └── main.pug │ │ │ └── partials │ │ │ └── footer.pug │ ├── overview │ │ ├── main.go │ │ └── templates │ │ │ ├── example.html │ │ │ ├── functions.html │ │ │ └── hi.html │ ├── parse-template │ │ ├── django │ │ │ └── main.go │ │ ├── handlebars │ │ │ └── main.go │ │ ├── jet │ │ │ └── main.go │ │ ├── main.go │ │ └── views │ │ │ └── layouts │ │ │ └── main.html │ ├── quicktemplate │ │ ├── README.md │ │ ├── controllers │ │ │ ├── execute_template.go │ │ │ ├── hello.go │ │ │ └── index.go │ │ ├── main.go │ │ ├── main_test.go │ │ ├── models │ │ │ └── .gitkeep │ │ └── templates │ │ │ ├── base.qtpl │ │ │ ├── base.qtpl.go │ │ │ ├── hello.qtpl │ │ │ ├── hello.qtpl.go │ │ │ ├── index.qtpl │ │ │ └── index.qtpl.go │ ├── templ │ │ ├── go.mod │ │ ├── go.sum │ │ ├── hello.templ │ │ ├── hello_templ.go │ │ └── main.go │ ├── template_ace_0 │ │ ├── main.go │ │ └── views │ │ │ ├── index.ace │ │ │ ├── layouts │ │ │ └── main.ace │ │ │ └── partials │ │ │ ├── footer.ace │ │ │ └── header.ace │ ├── template_blocks_0 │ │ ├── main.go │ │ └── views │ │ │ ├── 500.html │ │ │ ├── index.html │ │ │ ├── layouts │ │ │ ├── error.html │ │ │ └── main.html │ │ │ └── partials │ │ │ └── footer.html │ ├── template_blocks_1_embedded │ │ ├── bindata.go │ │ └── main.go │ ├── template_blocks_2 │ │ ├── main.go │ │ └── src │ │ │ └── public │ │ │ └── html │ │ │ ├── files │ │ │ └── list.html │ │ │ ├── layouts │ │ │ ├── main.html │ │ │ └── secondary.html │ │ │ └── menu │ │ │ └── menu.html │ ├── template_django_0 │ │ ├── main.go │ │ └── templates │ │ │ └── hi.html │ ├── template_django_1 │ │ ├── main.go │ │ └── views │ │ │ └── page.html │ ├── template_handlebars_0 │ │ ├── main.go │ │ └── templates │ │ │ └── example.html │ ├── template_html_0 │ │ ├── main.go │ │ └── templates │ │ │ └── hi.html │ ├── template_html_1 │ │ ├── main.go │ │ └── templates │ │ │ ├── layout.html │ │ │ └── mypage.html │ ├── template_html_2 │ │ ├── README.md │ │ ├── main.go │ │ └── templates │ │ │ ├── layouts │ │ │ ├── layout.html │ │ │ └── mylayout.html │ │ │ ├── page1.html │ │ │ └── partials │ │ │ └── page1_partial1.html │ ├── template_html_3 │ │ ├── main.go │ │ └── templates │ │ │ └── page.html │ ├── template_html_4 │ │ ├── hosts │ │ ├── main.go │ │ └── templates │ │ │ └── page.html │ ├── template_html_5 │ │ ├── main.go │ │ └── views │ │ │ ├── about.html │ │ │ ├── home.html │ │ │ ├── layout.html │ │ │ └── user │ │ │ └── index.html │ ├── template_jet_0 │ │ ├── README.md │ │ ├── main.go │ │ └── views │ │ │ ├── layouts │ │ │ └── application.jet │ │ │ └── todos │ │ │ ├── index.jet │ │ │ └── show.jet │ ├── template_jet_1_embedded │ │ ├── bindata.go │ │ ├── main.go │ │ └── views │ │ │ ├── includes │ │ │ ├── _partial.jet │ │ │ └── blocks.jet │ │ │ ├── index.jet │ │ │ └── layouts │ │ │ └── application.jet │ ├── template_jet_2 │ │ ├── main.go │ │ └── views │ │ │ └── page.jet │ ├── template_jet_3 │ │ ├── main.go │ │ └── views │ │ │ └── index.jet │ ├── template_pug_0 │ │ ├── main.go │ │ └── templates │ │ │ └── index.pug │ ├── template_pug_1 │ │ ├── main.go │ │ └── templates │ │ │ ├── footer.pug │ │ │ ├── header.pug │ │ │ └── index.pug │ ├── template_pug_2_embedded │ │ ├── bindata.go │ │ ├── main.go │ │ └── templates │ │ │ ├── index.pug │ │ │ └── layout.pug │ └── write-to │ │ ├── main.go │ │ └── views │ │ ├── email │ │ └── simple.html │ │ └── shared │ │ └── email.html ├── webassembly │ ├── client │ │ ├── go-wasm-runtime.js │ │ ├── hello.html │ │ ├── hello_go116.go │ │ └── main.js │ └── main.go └── websocket │ ├── README.md │ ├── basic │ ├── README.md │ ├── browser │ │ └── index.html │ ├── browserify │ │ ├── app.js │ │ ├── bundle.js │ │ ├── client.html │ │ └── package.json │ ├── go-client │ │ └── client.go │ ├── go.mod │ ├── go.sum │ ├── nodejs-client │ │ ├── client.js │ │ └── package.json │ ├── overview.png │ └── server.go │ ├── gorilla-filewatch │ ├── go.mod │ ├── go.sum │ ├── main.go │ ├── testfile.txt │ └── views │ │ └── home.html │ ├── native-messages │ ├── main.go │ ├── static │ │ └── js │ │ │ └── chat.js │ └── templates │ │ └── client.html │ ├── online-visitors │ ├── main.go │ ├── static │ │ └── assets │ │ │ └── js │ │ │ └── visitors.js │ └── templates │ │ ├── index.html │ │ └── other.html │ ├── secure │ └── README.md │ └── socketio │ ├── asset │ └── index.html │ ├── go.mod │ ├── go.sum │ └── main.go ├── _proposals ├── route_builder.md └── xerrors_party.md ├── aliases.go ├── apps ├── README.md ├── apps.go ├── switch.go ├── switch_hosts.go ├── switch_hosts_test.go ├── switch_options.go ├── switch_options_test.go ├── switch_scheme.go └── switch_test.go ├── auth ├── auth.go ├── configuration.go ├── provider.go └── user.go ├── cache ├── browser.go ├── browser_test.go ├── cache.go ├── cache_test.go ├── cfg │ └── cfg.go ├── client │ ├── client.go │ ├── handler.go │ ├── rule │ │ ├── chained.go │ │ ├── conditional.go │ │ ├── header.go │ │ ├── not_satisfied.go │ │ ├── rule.go │ │ ├── satisfied.go │ │ └── validator.go │ └── ruleset.go ├── entry │ ├── entry.go │ ├── pool.go │ ├── response.go │ └── store.go ├── ruleset │ └── ruleset.go └── uri │ └── uribuilder.go ├── cli.go ├── configuration.go ├── configuration_test.go ├── context ├── accept_header.go ├── application.go ├── compress.go ├── configuration.go ├── context.go ├── context_func.go ├── context_go118.go ├── context_user.go ├── counter.go ├── fs.go ├── handler.go ├── i18n.go ├── pool.go ├── problem.go ├── request_params.go ├── response_recorder.go ├── response_writer.go ├── route.go ├── status.go ├── strconv.go └── view.go ├── context_wrapper.go ├── core ├── errgroup │ ├── errgroup.go │ └── errgroup_test.go ├── handlerconv │ ├── from_std.go │ └── from_std_test.go ├── host │ ├── interrupt.go │ ├── proxy.go │ ├── proxy_test.go │ ├── supervisor.go │ ├── supervisor_task_example_test.go │ ├── supervisor_test.go │ ├── task.go │ └── waiter.go ├── memstore │ ├── gob.go │ ├── lifetime.go │ ├── memstore.go │ └── memstore_test.go ├── netutil │ ├── addr.go │ ├── addr_test.go │ ├── client.go │ ├── ip.go │ ├── ip_test.go │ ├── server.go │ ├── tcp.go │ ├── tcp_soreuse_control_unix.go │ ├── tcp_soreuse_control_wasm.go │ └── tcp_soreuse_control_windows.go └── router │ ├── TestUseRouterParentDisallow_fuzz_test.go │ ├── api_builder.go │ ├── api_builder_benchmark_test.go │ ├── api_container.go │ ├── fs.go │ ├── handler.go │ ├── handler_debug.go │ ├── handler_execution_rules.go │ ├── handler_execution_rules_test.go │ ├── mime.go │ ├── party.go │ ├── path.go │ ├── path_test.go │ ├── route.go │ ├── route_register_rule_test.go │ ├── route_test.go │ ├── router.go │ ├── router_handlers_order_test.go │ ├── router_subdomain_redirect.go │ ├── router_test.go │ ├── router_wildcard_root_test.go │ ├── router_wrapper.go │ ├── router_wrapper_test.go │ ├── status_test.go │ └── trie.go ├── doc.go ├── go.mod ├── go.sum ├── hero ├── binding.go ├── binding_test.go ├── container.go ├── container_test.go ├── dependency.go ├── dependency_source.go ├── dependency_test.go ├── func_result.go ├── func_result_test.go ├── handler.go ├── handler_test.go ├── param_test.go ├── reflect.go ├── reflect_test.go ├── struct.go └── struct_test.go ├── httptest ├── aliases.go ├── httptest.go ├── netutils.go ├── server.go └── status.go ├── i18n ├── i18n.go ├── internal │ ├── aliases.go │ ├── catalog.go │ ├── locale.go │ ├── message.go │ ├── plural.go │ ├── template.go │ └── var.go └── loader.go ├── iris.go ├── iris_guide.go ├── macro ├── handler │ ├── handler.go │ └── handler_test.go ├── interpreter │ ├── ast │ │ └── ast.go │ ├── lexer │ │ ├── lexer.go │ │ └── lexer_test.go │ ├── parser │ │ ├── parser.go │ │ └── parser_test.go │ └── token │ │ └── token.go ├── macro.go ├── macro_test.go ├── macros.go └── template.go ├── middleware ├── README.md ├── accesslog │ ├── accesslog.go │ ├── accesslog_test.go │ ├── broker.go │ ├── csv.go │ ├── csv_test.go │ ├── json.go │ ├── json_easy.go │ ├── log.go │ └── template.go ├── basicauth │ ├── basicauth.go │ ├── basicauth_test.go │ ├── error.go │ ├── header.go │ ├── header_test.go │ ├── user.go │ └── user_test.go ├── cors │ └── cors.go ├── grpc │ └── grpc.go ├── hcaptcha │ ├── ARTICLE.md │ └── hcaptcha.go ├── jwt │ ├── ARTICLE.md │ ├── aliases.go │ ├── blocklist.go │ ├── blocklist │ │ └── redis │ │ │ └── blocklist.go │ ├── extractor.go │ ├── jwt.go │ ├── jwt_test.go │ ├── signer.go │ └── verifier.go ├── logger │ ├── config.go │ └── logger.go ├── methodoverride │ ├── methodoverride.go │ └── methodoverride_test.go ├── modrevision │ └── modrevision.go ├── monitor │ ├── expvar_uint64.go │ ├── monitor.go │ ├── stats.go │ └── view.go ├── pprof │ └── pprof.go ├── rate │ └── rate.go ├── recaptcha │ └── recaptcha.go ├── recover │ └── recover.go ├── requestid │ ├── requestid.go │ └── requestid_test.go └── rewrite │ ├── rewrite.go │ └── rewrite_test.go ├── mvc ├── aliases.go ├── controller.go ├── controller_handle_test.go ├── controller_method_parser.go ├── controller_method_result_test.go ├── controller_overlap_test.go ├── controller_test.go ├── grpc.go ├── mvc.go ├── reflect.go └── versioning.go ├── sessions ├── config.go ├── database.go ├── provider.go ├── session.go ├── sessiondb │ ├── badger │ │ └── database.go │ ├── boltdb │ │ └── database.go │ └── redis │ │ ├── database.go │ │ ├── driver.go │ │ └── driver_goredis.go ├── sessions.go ├── sessions_test.go └── transcoding.go ├── versioning ├── deprecation.go ├── deprecation_test.go ├── group.go ├── group_test.go ├── version.go └── version_test.go ├── view ├── README.md ├── ace.go ├── blocks.go ├── django.go ├── fs.go ├── handlebars.go ├── html.go ├── jet.go ├── pug.go └── view.go ├── websocket ├── aliases.go └── websocket.go └── x ├── client ├── client.go ├── client_test.go ├── error.go ├── handler_transport.go ├── option.go └── request_handler.go ├── errors ├── aliases.go ├── context_error_handler.go ├── errors.go ├── handlers.go ├── path_parameter_type_error_handler.go ├── validation │ ├── error.go │ ├── number.go │ ├── slice.go │ └── string.go └── validation_error.go ├── jsonx ├── day_time.go ├── day_time_test.go ├── duration.go ├── exampler.go ├── iso8601.go ├── iso8601_test.go ├── jsonx.go ├── kitchen_time.go ├── kitchen_time_test.go ├── season.go ├── simple_date.go ├── simple_date_test.go └── time_notation.go ├── mathx └── round.go ├── pagination └── pagination.go ├── reflex ├── error.go ├── func.go ├── reflex.go ├── struct.go ├── types.go └── zero.go ├── sqlx ├── sqlx.go ├── sqlx_test.go ├── struct_row.go └── util.go └── timex ├── weekday.go └── weekday_test.go /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | test_patterns = ["**/*_test.go"] 4 | 5 | exclude_patterns = [ 6 | "_examples/**", 7 | "_benchmarks/**", 8 | ".github/**" 9 | ] 10 | 11 | [[analyzers]] 12 | name = "go" 13 | enabled = true 14 | 15 | [analyzers.meta] 16 | import_paths = ["github.com/kataras/iris/v12"] 17 | -------------------------------------------------------------------------------- /.fossa.yml: -------------------------------------------------------------------------------- 1 | version: 3 2 | cli: 3 | server: https://app.fossa.com 4 | fetcher: git 5 | package: github.com/kataras/iris 6 | project: github.com/kataras/iris 7 | analyze: 8 | modules: 9 | - name: iris 10 | type: go 11 | target: . 12 | path: . -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.go linguist-language=Go 2 | _examples/* linguist-documentation 3 | _benchmarks/* linguist-documentation 4 | go.sum linguist-generated 5 | # Set the default behavior, in case people don't have core.autocrlf set. 6 | # if from windows: 7 | # git config --global core.autocrlf true 8 | # if from unix: 9 | # git config --global core.autocrlf input 10 | # https://help.github.com/articles/dealing-with-line-endings/#per-repository-settings 11 | * text=auto 12 | # ignore perms 13 | # git config core.filemode false 14 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in the repo. 2 | * @kataras 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # patreon: # Replace with a single Patreon username 2 | # open_collective: # Replace with a single Open Collective username 3 | # ko_fi: # Replace with a single Ko-fi username 4 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 5 | # custom: https://iris-go.com/donate # Replace with a single custom sponsorship URL 6 | github: kataras -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Examples for the Iris project can be found at 2 | . 3 | 4 | Documentation for the Iris project can be found at 5 | . 6 | 7 | Love iris? Please consider supporting the project: 8 | 👉 https://iris-go.com/donate 9 | 10 | Care to be part of a larger community? Fill our user experience form: 11 | 👉 https://goo.gl/forms/lnRbVgA6ICTkPyk02 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Other 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Describe the issue you are facing or ask for help 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE REQUEST]" 5 | labels: type:idea 6 | assignees: kataras 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # We'd love to see more contributions 2 | 3 | Read how you can [contribute to the project](https://github.com/kataras/iris/blob/main/CONTRIBUTING.md). 4 | 5 | > Please attach an [issue](https://github.com/kataras/iris/issues) link which your PR solves otherwise your work may be rejected. 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gomod" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" -------------------------------------------------------------------------------- /.github/scripts/setup_examples_test.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | for f in ../../_examples/*; do 4 | if [ -d "$f" ]; then 5 | # Will not run if no directories are available 6 | go mod init 7 | go get -u github.com/kataras/iris/v12@main 8 | go mod download 9 | go run . 10 | fi 11 | done 12 | 13 | # git update-index --chmod=+x ./.github/scripts/setup_examples_test.bash -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | .directory 4 | coverage.out 5 | package-lock.json 6 | access.log 7 | node_modules 8 | issue-*/ 9 | internalcode-*/ 10 | /_examples/feature-*/ 11 | _examples/**/uploads/* 12 | _issues/** 13 | .DS_STORE 14 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Iris authors for copyright 2 | # purposes. 3 | 4 | Gerasimos Maropoulos 5 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | We are focusing on fixing issues and security vulnerabilities to the latest and greatest version of Iris. 6 | Iris users SHOULD always update their backend code to the latest version of Iris API, there is a complete [HISTORY](https://github.com/kataras/iris/blob/main/HISTORY.md) file 7 | which acts as a code migration assistant. 8 | 9 | ## Reporting a Vulnerability 10 | 11 | Please report (suspected) security vulnerabilities to 12 | **[iris-go@outlook.com](mailto:iris-go@outlook.com)**. You will receive a response from 13 | us within 3-4 working days. If the issue is confirmed, we will release a new minor version as soon 14 | as possible depending on complexity but historically within a few hours or days. 15 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | v12.2.0:https://github.com/kataras/iris/tree/v12.2.0 -------------------------------------------------------------------------------- /_benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | - [HTTP/2 Benchmarks](https://github.com/kataras/server-benchmarks#benchmarks) 4 | - [View Engine Benchmarks](./view) 5 | -------------------------------------------------------------------------------- /_benchmarks/view/ace/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | // By default Ace engine minifies the template before render. 12 | app.RegisterView(iris.Ace("./views", ".ace").SetIndent("")) 13 | 14 | app.Get("/", index) 15 | 16 | app.Listen(":8080") 17 | } 18 | 19 | func index(ctx iris.Context) { 20 | data := iris.Map{ 21 | "Title": "Page Title", 22 | "FooterText": "Footer contents", 23 | "Message": "Main contents", 24 | } 25 | 26 | ctx.ViewLayout("layouts/main") 27 | if err := ctx.View("index", data); err != nil { 28 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 29 | return 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /_benchmarks/view/ace/views/index.ace: -------------------------------------------------------------------------------- 1 | h1 Index Body 2 | h3 Message: {{.Message}} -------------------------------------------------------------------------------- /_benchmarks/view/ace/views/layouts/main.ace: -------------------------------------------------------------------------------- 1 | = doctype html 2 | html 3 | head 4 | title {{.Title}} 5 | body 6 | {{ yield . }} 7 | footer 8 | = include partials/footer.ace . 9 | -------------------------------------------------------------------------------- /_benchmarks/view/ace/views/partials/footer.ace: -------------------------------------------------------------------------------- 1 | h3 Footer Partial 2 | h4 {{.FooterText}} -------------------------------------------------------------------------------- /_benchmarks/view/blocks/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.RegisterView(iris.Blocks("./views", ".html")) 12 | // Note, in Blocks engine, layouts 13 | // are used by their base names, the 14 | // blocks.LayoutDir(layoutDir) defaults to "./layouts". 15 | 16 | app.Get("/", index) 17 | 18 | app.Listen(":8080") 19 | } 20 | 21 | func index(ctx iris.Context) { 22 | data := iris.Map{ 23 | "Title": "Page Title", 24 | "FooterText": "Footer contents", 25 | "Message": "Main contents", 26 | } 27 | 28 | ctx.ViewLayout("main") 29 | if err := ctx.View("index", data); err != nil { 30 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_benchmarks/view/blocks/views/index.html: -------------------------------------------------------------------------------- 1 |

Index Body

Message: {{.Message}}

-------------------------------------------------------------------------------- /_benchmarks/view/blocks/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | {{.Title}}{{ template "content" . }}
{{ partial "partials/footer" . }}
-------------------------------------------------------------------------------- /_benchmarks/view/blocks/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

Footer Partial

{{.FooterText}}

-------------------------------------------------------------------------------- /_benchmarks/view/chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_benchmarks/view/chart.png -------------------------------------------------------------------------------- /_benchmarks/view/django/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.RegisterView(iris.Django("./views", ".html")) 12 | 13 | app.Get("/", index) 14 | 15 | app.Listen(":8080") 16 | } 17 | 18 | func index(ctx iris.Context) { 19 | data := iris.Map{ 20 | "Title": "Page Title", 21 | "FooterText": "Footer contents", 22 | "Message": "Main contents", 23 | } 24 | 25 | // On Django this is ignored: ctx.ViewLayout("layouts/main") 26 | // Layouts are only rendered from inside the index page itself 27 | // using the "extends" keyword. 28 | if err := ctx.View("index", data); err != nil { 29 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 30 | return 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_benchmarks/view/django/views/index.html: -------------------------------------------------------------------------------- 1 | {% extends "layouts/main.html" %}{% block content %}

Index Body

Message: {{Message}}

{% endblock %} -------------------------------------------------------------------------------- /_benchmarks/view/django/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | {{Title}}{% block content %} {% endblock %}
{% include "../partials/footer.html" %}
-------------------------------------------------------------------------------- /_benchmarks/view/django/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

Footer Partial

{{FooterText}}

-------------------------------------------------------------------------------- /_benchmarks/view/handlebars/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.RegisterView(iris.Handlebars("./views", ".html")) 12 | 13 | app.Get("/", index) 14 | 15 | app.Listen(":8080") 16 | } 17 | 18 | func index(ctx iris.Context) { 19 | data := iris.Map{ 20 | "Title": "Page Title", 21 | "FooterText": "Footer contents", 22 | "Message": "Main contents", 23 | } 24 | 25 | ctx.ViewLayout("layouts/main") 26 | if err := ctx.View("index", data); err != nil { 27 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 28 | return 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /_benchmarks/view/handlebars/views/index.html: -------------------------------------------------------------------------------- 1 |

Index Body

Message: {{Message}}

-------------------------------------------------------------------------------- /_benchmarks/view/handlebars/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | {{Title}}{{ yield . }}
{{ render "partials/footer.html" .}}
-------------------------------------------------------------------------------- /_benchmarks/view/handlebars/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

Footer Partial

{{FooterText}}

-------------------------------------------------------------------------------- /_benchmarks/view/html/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | 12 | app.RegisterView(iris.HTML("./views", ".html")) 13 | 14 | app.Get("/", index) 15 | 16 | app.Listen(":8080") 17 | } 18 | 19 | func index(ctx iris.Context) { 20 | data := iris.Map{ 21 | "Title": "Page Title", 22 | "FooterText": "Footer contents", 23 | "Message": "Main contents", 24 | } 25 | 26 | ctx.ViewLayout("layouts/main") 27 | if err := ctx.View("index", data); err != nil { 28 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 29 | return 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /_benchmarks/view/html/views/index.html: -------------------------------------------------------------------------------- 1 |

Index Body

Message: {{.Message}}

-------------------------------------------------------------------------------- /_benchmarks/view/html/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | {{.Title}}{{ yield . }}
{{ render "partials/footer.html" . }}
-------------------------------------------------------------------------------- /_benchmarks/view/html/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

Footer Partial

{{.FooterText}}

-------------------------------------------------------------------------------- /_benchmarks/view/jet/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.RegisterView(iris.Jet("./views", ".jet")) 12 | 13 | app.Get("/", index) 14 | 15 | app.Listen(":8080") 16 | } 17 | 18 | func index(ctx iris.Context) { 19 | data := iris.Map{ 20 | "Title": "Page Title", 21 | "FooterText": "Footer contents", 22 | "Message": "Main contents", 23 | } 24 | 25 | // On Jet this is ignored: ctx.ViewLayout("layouts/main") 26 | // Layouts are only rendered from inside the index page itself 27 | // using the "extends" keyword. 28 | if err := ctx.View("index", data); err != nil { 29 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 30 | return 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_benchmarks/view/jet/views/index.jet: -------------------------------------------------------------------------------- 1 | {{ extends "../layouts/main.jet" }}{{ block documentBody() }}

Index Body

Message: {{.Message}}

{{ end }} -------------------------------------------------------------------------------- /_benchmarks/view/jet/views/layouts/main.jet: -------------------------------------------------------------------------------- 1 | {{.Title}}{{ yield documentBody() }}
{{ include "../partials/footer.jet" . }}
-------------------------------------------------------------------------------- /_benchmarks/view/jet/views/partials/footer.jet: -------------------------------------------------------------------------------- 1 |

Footer Partial

{{.FooterText}}

-------------------------------------------------------------------------------- /_benchmarks/view/pug/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | // Ace engine minifies the template before render. 12 | app.RegisterView(iris.Pug("./views", ".pug")) 13 | 14 | app.Get("/", index) 15 | 16 | app.Listen(":8080") 17 | } 18 | 19 | func index(ctx iris.Context) { 20 | data := iris.Map{ 21 | "Title": "Page Title", 22 | "FooterText": "Footer contents", 23 | "Message": "Main contents", 24 | } 25 | 26 | // On Pug this is ignored: ctx.ViewLayout("layouts/main") 27 | // Layouts are only rendered from inside the index page itself 28 | // using the "extends" keyword. 29 | if err := ctx.View("index", data); err != nil { 30 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_benchmarks/view/pug/views/index.pug: -------------------------------------------------------------------------------- 1 | extends layouts/main.pug 2 | 3 | block content 4 | h1 Index Body 5 | h3 Message: {{.Message}} -------------------------------------------------------------------------------- /_benchmarks/view/pug/views/layouts/main.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title {{.Title}} 5 | body 6 | block content 7 | footer 8 | include ../partials/footer.pug -------------------------------------------------------------------------------- /_benchmarks/view/pug/views/partials/footer.pug: -------------------------------------------------------------------------------- 1 | h3 Footer Partial 2 | h4 {{.FooterText}} -------------------------------------------------------------------------------- /_benchmarks/view/tests.yml: -------------------------------------------------------------------------------- 1 | - Name: Template Layout, Partial and Data 2 | Description: > 3 | Fires {{.NumberOfRequests}} requests with {{.NumberOfConnections}} concurrent clients. 4 | It receives HTML response. 5 | The server handler sets some template **data** and renders a 6 | template file which consists of a **layout** and a **partial** footer. 7 | NumberOfRequests: 1000000 8 | NumberOfConnections: 125 9 | Method: GET 10 | URL: http://localhost:8080 11 | Envs: 12 | - Name: Ace 13 | Dir: ./ace 14 | - Name: Blocks 15 | Dir: ./blocks 16 | - Name: Django 17 | Dir: ./django 18 | - Name: Handlebars 19 | Dir: ./handlebars 20 | - Name: HTML 21 | Dir: ./html 22 | - Name: Jet 23 | Dir: ./jet 24 | - Name: Pug 25 | Dir: ./pug 26 | -------------------------------------------------------------------------------- /_examples/apidoc/swagger/README.md: -------------------------------------------------------------------------------- 1 | # Swagger 2.0 2 | 3 | Visit https://github.com/iris-contrib/swagger instead. 4 | -------------------------------------------------------------------------------- /_examples/auth/auth/README.md: -------------------------------------------------------------------------------- 1 | # Auth Package (+ Single Sign On) 2 | 3 | ```sh 4 | $ go run . 5 | ``` 6 | 7 | 1. GET/POST: http://localhost:8080/signin 8 | 2. GET: http://localhost:8080/member 9 | 3. GET: http://localhost:8080/owner 10 | 4. POST: http://localhost:8080/refresh 11 | 5. GET: http://localhost:8080/signout 12 | 6. GET: http://localhost:8080/signout-all -------------------------------------------------------------------------------- /_examples/auth/auth/user.go: -------------------------------------------------------------------------------- 1 | //go:build go1.18 2 | // +build go1.18 3 | 4 | package main 5 | 6 | type AccessRole uint16 7 | 8 | func (r AccessRole) Is(v AccessRole) bool { 9 | return r&v != 0 10 | } 11 | 12 | func (r AccessRole) Allow(v AccessRole) bool { 13 | return r&v >= v 14 | } 15 | 16 | const ( 17 | InvalidAccessRole AccessRole = 1 << iota 18 | Read 19 | Write 20 | Delete 21 | 22 | Owner = Read | Write | Delete 23 | Member = Read | Write 24 | ) 25 | 26 | type User struct { 27 | ID string `json:"id"` 28 | Email string `json:"email"` 29 | Role AccessRole `json:"role"` 30 | } 31 | 32 | func (u User) GetID() string { 33 | return u.ID 34 | } 35 | -------------------------------------------------------------------------------- /_examples/auth/auth/views/partials/footer.html: -------------------------------------------------------------------------------- 1 | Iris Web Framework © 2022 -------------------------------------------------------------------------------- /_examples/auth/auth/views/signin.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_examples/auth/basicauth/database/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker build -t myapp . 2 | # docker run --rm -it -p 8080:8080 myapp:latest 3 | FROM golang:latest AS builder 4 | RUN apt-get update 5 | ENV GO111MODULE=on \ 6 | CGO_ENABLED=0 \ 7 | GOOS=linux \ 8 | GOARCH=amd64 9 | WORKDIR /go/src/app 10 | COPY go.mod . 11 | RUN go mod download 12 | # cache step 13 | COPY . . 14 | RUN go install 15 | 16 | FROM scratch 17 | COPY --from=builder /go/bin/myapp . 18 | ENTRYPOINT ["./myapp"] -------------------------------------------------------------------------------- /_examples/auth/basicauth/database/migration/db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS myapp DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 2 | 3 | USE myapp; 4 | 5 | SET NAMES utf8mb4; 6 | SET FOREIGN_KEY_CHECKS = 0; 7 | 8 | DROP TABLE IF EXISTS users; 9 | CREATE TABLE users ( 10 | id int(11) NOT NULL AUTO_INCREMENT, 11 | username varchar(255) NOT NULL, 12 | password varchar(255) NOT NULL, 13 | email varchar(255) NOT NULL, 14 | PRIMARY KEY (id) 15 | ); 16 | 17 | INSERT INTO users (username,password,email) 18 | VALUES 19 | ('admin', 'admin', 'kataras2006@hotmail.com'), 20 | ("iris", 'iris_password', 'iris-go@outlook.com'); 21 | 22 | SET FOREIGN_KEY_CHECKS = 1; -------------------------------------------------------------------------------- /_examples/auth/basicauth/users_file_bcrypt/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | "github.com/kataras/iris/v12/middleware/basicauth" 6 | ) 7 | 8 | func main() { 9 | auth := basicauth.Load("users.yml", basicauth.BCRYPT) 10 | /* Same as: 11 | opts := basicauth.Options{ 12 | Realm: basicauth.DefaultRealm, 13 | Allow: basicauth.AllowUsersFile("users.yml", basicauth.BCRYPT), 14 | } 15 | 16 | auth := basicauth.New(opts) 17 | */ 18 | 19 | app := iris.New() 20 | app.Use(auth) 21 | app.Get("/", index) 22 | // kataras:kataras_pass 23 | // makis:makis_pass 24 | app.Listen(":8080") 25 | } 26 | 27 | func index(ctx iris.Context) { 28 | user := ctx.User() 29 | ctx.JSON(user) 30 | } 31 | -------------------------------------------------------------------------------- /_examples/auth/basicauth/users_file_bcrypt/users.yml: -------------------------------------------------------------------------------- 1 | # The file cannot be modified during the serve time. 2 | # To support real-time users changes please use the Options.Allow instead, 3 | # (see the database example for that). 4 | # 5 | # Again, the username and password (or capitalized) fields are required, 6 | # the rest are optional, depending on your application needs. 7 | - username: kataras 8 | password: $2a$10$Irg8k8HWkDlvL0YDBKLCYee6j6zzIFTplJcvZYKA.B8/clHPZn2Ey # encrypted of kataras_pass 9 | age: 27 10 | role: admin 11 | - username: makis 12 | password: $2a$10$3GXzp3J5GhHThGisbpvpZuftbmzPivDMo94XPnkTnDe7254x7sJ3O # encrypted of makis_pass 13 | -------------------------------------------------------------------------------- /_examples/auth/cors/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Iris Cors Example 8 | 9 | 10 | 11 |
    12 |
13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /_examples/auth/goth/templates/index.html: -------------------------------------------------------------------------------- 1 | {{range $key,$value:=.Providers}} 2 |

Log in with {{index $.ProvidersMap $value}}

3 | {{end}} -------------------------------------------------------------------------------- /_examples/auth/goth/templates/user.html: -------------------------------------------------------------------------------- 1 |

logout

2 |

Name: {{.Name}} [{{.LastName}}, {{.FirstName}}]

3 |

Email: {{.Email}}

4 |

NickName: {{.NickName}}

5 |

Location: {{.Location}}

6 |

AvatarURL: {{.AvatarURL}}

7 |

Description: {{.Description}}

8 |

UserID: {{.UserID}}

9 |

AccessToken: {{.AccessToken}}

10 |

ExpiresAt: {{.ExpiresAt}}

11 |

RefreshToken: {{.RefreshToken}}

12 | 13 |
14 | 15 |

Iterate all properties

16 | 17 | {{range $key, $value := .RawData}} 18 | {{ $key }} => {{ $value }}
19 | {{end}} 20 | -------------------------------------------------------------------------------- /_examples/auth/hcaptcha/hosts: -------------------------------------------------------------------------------- 1 | # https://docs.hcaptcha.com/#localdev 2 | # Add to the end of your hosts file, e.g. on windows: C:/windows/system32/drivers/etc/hosts 3 | 127.0.0.1 yourdomain.com 4 | -------------------------------------------------------------------------------- /_examples/auth/hcaptcha/templates/register_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hCaptcha Demo 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /_examples/auth/jwt/refresh-token/rsa_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArwO0q8WbBvrplz3lTQjs 3 | Wu66HC7M3mVAjmjLq8Wj/ipqVtiJMrUL9t/0q9PNO/KX9u+HayFNYM4TnYkXVZX3 4 | M5E31W8fPPy74D/XpqFwrwT7bAEwpT51JJyxkoBAyOh08lmR2EYvpGF7qErra7qb 5 | kk4LGFbhoFCXdMLXguT4rPymkzFHdQrmGYOBS+v9imSuJddCZpXyv6Ko7AKB4mhz 6 | g4RC5RJZO5GEHVUrSMHxZB0syF8cU+28iL8A7SlGKTNZPZiHmCQVRqA6WlllL/YV 7 | /t6p24kaNZBUp9JGbAzOeKuVUv2uvfNKwB/aBwnFKauM9I6RmC4bnI1nGHjETlNN 8 | WwIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/api/router.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "myapp/domain/repository" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | // NewRouter accepts some dependencies 10 | // and returns a function which returns the routes on the given Iris Party (group of routes). 11 | func NewRouter(userRepo repository.UserRepository, todoRepo repository.TodoRepository) func(iris.Party) { 12 | return func(router iris.Party) { 13 | router.Post("/signin", SignIn(userRepo)) 14 | 15 | router.Use(Verify()) // protect the next routes with JWT. 16 | 17 | router.Post("/todos", CreateTodo(todoRepo)) 18 | router.Get("/todos", ListTodos(todoRepo)) 19 | router.Get("/todos/{id}", GetTodo(todoRepo)) 20 | 21 | router.Get("/admin/todos", AllowAdmin, ListAllTodos(todoRepo)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/domain/model/role.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // Role represents a role. 4 | type Role string 5 | 6 | const ( 7 | // Admin represents the Admin access role. 8 | Admin Role = "admin" 9 | ) 10 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/domain/model/todo.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // Todo represents the Todo model. 4 | type Todo struct { 5 | ID string `json:"id"` 6 | UserID string `json:"user_id"` 7 | Title string `json:"title"` 8 | Body string `json:"body"` 9 | CreatedAt int64 `json:"created_at"` // unix seconds. 10 | } 11 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/domain/model/user.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // User represents our User model. 4 | type User struct { 5 | ID string `json:"id"` 6 | Username string `json:"username"` 7 | HashedPassword []byte `json:"-"` 8 | Roles []Role `json:"roles"` 9 | } 10 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/go-client/README.md: -------------------------------------------------------------------------------- 1 | # Go Client 2 | 3 | ```sh 4 | $ go run . 5 | ``` 6 | 7 | ```sh 8 | 2020/11/04 21:08:40 Access Token: 9 | "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiYTAwYzI3ZDEtYjVhYS00NjU0LWFmMTYtYjExNzNkZTY1NjI5Iiwicm9sZXMiOlsiYWRtaW4iXSwiaWF0IjoxNjA0NTE2OTIwLCJleHAiOjE2MDQ1MTc4MjAsImp0aSI6IjYzNmVmMDc0LTE2MzktNGJhZi1hNGNiLTQ4ZDM4NGMxMzliYSIsImlzcyI6Im15YXBwIn0.T9B0zG0AHShO5JfQgrMQBlToH33KHgp8nLMPFpN6QmM" 10 | 2020/11/04 21:08:40 Todo Created: 11 | model.Todo{ID:"cfa38d7a-c556-4301-ae1f-fb90f705071c", UserID:"a00c27d1-b5aa-4654-af16-b1173de65629", Title:"test todo title", Body:"test todo body contents", CreatedAt:1604516920} 12 | ``` 13 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "myapp/api" 5 | "myapp/domain/repository" 6 | 7 | "github.com/kataras/iris/v12" 8 | ) 9 | 10 | var ( 11 | userRepo = repository.NewMemoryUserRepository() 12 | todoRepo = repository.NewMemoryTodoRepository() 13 | ) 14 | 15 | func main() { 16 | if err := repository.GenerateSamples(userRepo, todoRepo); err != nil { 17 | panic(err) 18 | } 19 | 20 | app := iris.New() 21 | app.PartyFunc("/", api.NewRouter(userRepo, todoRepo)) 22 | 23 | // POST http://localhost:8080/signin (Form: username, password) 24 | // GET http://localhost:8080/todos 25 | // GET http://localhost:8080/todos/{id} 26 | // POST http://localhost:8080/todos (JSON, Form or URL: title, body) 27 | // GET http://localhost:8080/admin/todos 28 | app.Listen(":8080") 29 | } 30 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/util/app.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | // Constants for the application. 4 | const ( 5 | Version = "0.0.1" 6 | AppName = "myapp" 7 | ) 8 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/util/clock.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "time" 4 | 5 | // Now is the default current time for the whole application. 6 | // Can be modified for testing or custom timezone. 7 | var Now = time.Now 8 | -------------------------------------------------------------------------------- /_examples/auth/jwt/tutorial/util/uuid.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "github.com/google/uuid" 4 | 5 | // MustGenerateUUID returns a new v4 UUID or panics. 6 | func MustGenerateUUID() string { 7 | id, err := GenerateUUID() 8 | if err != nil { 9 | panic(err) 10 | } 11 | 12 | return id 13 | } 14 | 15 | // GenerateUUID returns a new v4 UUID. 16 | func GenerateUUID() (string, error) { 17 | id, err := uuid.NewRandom() 18 | if err != nil { 19 | return "", err 20 | } 21 | 22 | return id.String(), nil 23 | } 24 | -------------------------------------------------------------------------------- /_examples/bootstrapper/folder_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/bootstrapper/folder_structure.png -------------------------------------------------------------------------------- /_examples/bootstrapper/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/_examples/bootstrapper/bootstrap" 5 | "github.com/kataras/iris/v12/_examples/bootstrapper/middleware/identity" 6 | "github.com/kataras/iris/v12/_examples/bootstrapper/routes" 7 | ) 8 | 9 | func newApp() *bootstrap.Bootstrapper { 10 | app := bootstrap.New("Awesome App", "kataras2006@hotmail.com") 11 | app.Bootstrap() 12 | app.Configure(identity.Configure, routes.Configure) 13 | return app 14 | } 15 | 16 | func main() { 17 | app := newApp() 18 | app.Listen(":8080") 19 | } 20 | -------------------------------------------------------------------------------- /_examples/bootstrapper/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/bootstrapper/public/favicon.ico -------------------------------------------------------------------------------- /_examples/bootstrapper/routes/follower.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | // GetFollowerHandler handles the GET: /follower/{id} 8 | func GetFollowerHandler(ctx iris.Context) { 9 | id, _ := ctx.Params().GetInt64("id") 10 | ctx.Writef("from "+ctx.GetCurrentRoute().Path()+" with ID: %d", id) 11 | } 12 | -------------------------------------------------------------------------------- /_examples/bootstrapper/routes/following.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | // GetFollowingHandler handles the GET: /following/{id} 8 | func GetFollowingHandler(ctx iris.Context) { 9 | id, _ := ctx.Params().GetInt64("id") 10 | ctx.Writef("from "+ctx.GetCurrentRoute().Path()+" with ID: %d", id) 11 | } 12 | -------------------------------------------------------------------------------- /_examples/bootstrapper/routes/index.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | // GetIndexHandler handles the GET: / 10 | func GetIndexHandler(ctx iris.Context) { 11 | ctx.ViewData("Title", "Index Page") 12 | if err := ctx.View("index.html"); err != nil { 13 | ctx.HTML(fmt.Sprintf("

%s

", err.Error())) 14 | return 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /_examples/bootstrapper/routes/like.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | // GetLikeHandler handles the GET: /like/{id} 8 | func GetLikeHandler(ctx iris.Context) { 9 | id, _ := ctx.Params().GetInt64("id") 10 | ctx.Writef("from "+ctx.GetCurrentRoute().Path()+" with ID: %d", id) 11 | } 12 | -------------------------------------------------------------------------------- /_examples/bootstrapper/routes/routes.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/_examples/bootstrapper/bootstrap" 5 | ) 6 | 7 | // Configure registers the necessary routes to the app. 8 | func Configure(b *bootstrap.Bootstrapper) { 9 | b.Get("/", GetIndexHandler) 10 | b.Get("/follower/{id:int64}", GetFollowerHandler) 11 | b.Get("/following/{id:int64}", GetFollowingHandler) 12 | b.Get("/like/{id:int64}", GetLikeHandler) 13 | } 14 | -------------------------------------------------------------------------------- /_examples/bootstrapper/views/index.html: -------------------------------------------------------------------------------- 1 |

Welcome!!

-------------------------------------------------------------------------------- /_examples/bootstrapper/views/shared/error.html: -------------------------------------------------------------------------------- 1 | 

Error.

2 |

An error occurred while processing your request.

3 | 4 |

{{.Err.status}}

5 |

{{.Err.message}}

-------------------------------------------------------------------------------- /_examples/bootstrapper/views/shared/layout.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | {{.Title}} - {{.AppName}} 9 | 10 | 11 | 12 | 13 |
14 | 15 | {{ yield . }} 16 |
17 |
18 |

© 2017 - {{.AppOwner}}

19 |
20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /_examples/caddy/Caddyfile: -------------------------------------------------------------------------------- 1 | example.com { 2 | header / Server "Iris" 3 | proxy / example.com:9091 # localhost:9091 4 | } 5 | 6 | api.example.com { 7 | header / Server "Iris" 8 | proxy / api.example.com:9092 # localhost:9092 9 | } -------------------------------------------------------------------------------- /_examples/caddy/server1/views/index.html: -------------------------------------------------------------------------------- 1 |
2 | {{.Message}} 3 |
-------------------------------------------------------------------------------- /_examples/caddy/server1/views/shared/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{.Layout.Title}} 5 | 6 | 7 | 8 | {{ yield . }} 9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/configuration/from-toml-file/configs/iris.tml: -------------------------------------------------------------------------------- 1 | DisablePathCorrection = false 2 | EnablePathEscape = false 3 | FireMethodNotAllowed = true 4 | DisableBodyConsumptionOnUnmarshal = false 5 | TimeFormat = "Mon, 01 Jan 2006 15:04:05 GMT" 6 | Charset = "utf-8" 7 | RemoteAddrHeaders = ["X-Real-Ip", "X-Forwarded-For", "CF-Connecting-IP"] 8 | [Other] 9 | MyServerName = "iris" 10 | -------------------------------------------------------------------------------- /_examples/configuration/from-toml-file/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func main() { 8 | app := iris.New() 9 | 10 | app.Get("/", func(ctx iris.Context) { 11 | ctx.HTML("Hello!") 12 | }) 13 | // [...] 14 | 15 | // Good when you have two configurations, one for development and a different one for production use. 16 | app.Listen(":8080", iris.WithConfiguration(iris.TOML("./configs/iris.tml"))) 17 | 18 | // or before run: 19 | // app.Configure(iris.WithConfiguration(iris.TOML("./configs/iris.tml"))) 20 | // app.Listen(":8080") 21 | } 22 | -------------------------------------------------------------------------------- /_examples/configuration/from-yaml-file/configs/iris.yml: -------------------------------------------------------------------------------- 1 | DisablePathCorrection: false 2 | EnablePathEscape: false 3 | FireMethodNotAllowed: true 4 | DisableBodyConsumptionOnUnmarshal: true 5 | TimeFormat: Mon, 01 Jan 2006 15:04:05 GMT 6 | Charset: UTF-8 7 | SSLProxyHeaders: 8 | X-Forwarded-Proto: https 9 | HostProxyHeaders: 10 | X-Host: true 11 | RemoteAddrHeaders: 12 | - X-Real-Ip 13 | - X-Forwarded-For 14 | - CF-Connecting-IP 15 | Other: 16 | Addr: :8080 17 | -------------------------------------------------------------------------------- /_examples/configuration/from-yaml-file/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func main() { 8 | app := iris.New() 9 | app.Get("/", func(ctx iris.Context) { 10 | ctx.HTML("Hello!") 11 | }) 12 | // [...] 13 | 14 | // Good when you have two configurations, one for development and a different one for production use. 15 | // If iris.YAML's input string argument is "~" then it loads the configuration from the home directory 16 | // and can be shared between many iris instances. 17 | cfg := iris.YAML("./configs/iris.yml") 18 | addr := cfg.Other["Addr"].(string) 19 | app.Listen(addr, iris.WithConfiguration(cfg)) 20 | 21 | // or before run: 22 | // app.Configure(iris.WithConfiguration(iris.YAML("./configs/iris.yml"))) 23 | // app.Listen(":8080") 24 | } 25 | -------------------------------------------------------------------------------- /_examples/configuration/from-yaml-file/shared-configuration/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func main() { 8 | app := iris.New() 9 | app.Get("/", func(ctx iris.Context) { 10 | ctx.HTML("Hello!") 11 | }) 12 | // [...] 13 | 14 | // Good when you share configuration between multiple iris instances. 15 | // This configuration file lives in your $HOME/iris.yml for unix hosts 16 | // or %HOMEDRIVE%+%HOMEPATH%/iris.yml for windows hosts, and you can modify it. 17 | app.Listen(":8080", iris.WithGlobalConfiguration) 18 | // or before run: 19 | // app.Configure(iris.WithGlobalConfiguration) 20 | // app.Listen(":8080") 21 | } 22 | -------------------------------------------------------------------------------- /_examples/configuration/functional/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func main() { 8 | app := iris.New() 9 | app.Get("/", func(ctx iris.Context) { 10 | ctx.HTML("Hello!") 11 | }) 12 | // [...] 13 | 14 | // Good when you want to change some of the configuration's field. 15 | // Prefix: "With", code editors will help you navigate through all 16 | // configuration options without even a glitch to the documentation. 17 | 18 | app.Listen(":8080", iris.WithoutStartupLog, iris.WithCharset("utf-8")) 19 | 20 | // or before run: 21 | // app.Configure(iris.WithoutStartupLog, iris.WithCharset("utf-8")) 22 | // app.Listen(":8080") 23 | } 24 | -------------------------------------------------------------------------------- /_examples/configuration/multi-environments/README.md: -------------------------------------------------------------------------------- 1 | # Environment-based Configuration 2 | 3 | ## Run production server 4 | 5 | ```sh 6 | $ go run main.go --config=server.yml 7 | ``` 8 | 9 | ## Run development server 10 | 11 | ```sh 12 | $ go run main.go --config=server.dev.yml 13 | ``` 14 | -------------------------------------------------------------------------------- /_examples/configuration/multi-environments/api/configuration.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/kataras/iris/v12" 7 | "gopkg.in/yaml.v3" 8 | ) 9 | 10 | type Configuration struct { 11 | Host string `yaml:"Host"` 12 | Port int `yaml:"Port"` 13 | EnableCompression bool `yaml:"EnableCompression"` 14 | AllowOrigin string `yaml:"AllowOrigin"` 15 | // Iris specific configuration. 16 | Iris iris.Configuration `yaml:"Iris"` 17 | } 18 | 19 | // BindFile binds the yaml file's contents to this Configuration. 20 | func (c *Configuration) BindFile(filename string) error { 21 | contents, err := os.ReadFile(filename) 22 | if err != nil { 23 | return err 24 | } 25 | 26 | return yaml.Unmarshal(contents, c) 27 | } 28 | -------------------------------------------------------------------------------- /_examples/configuration/multi-environments/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/kataras/my-iris-app/cmd" 8 | ) 9 | 10 | func main() { 11 | app := cmd.New() 12 | if err := app.Execute(); err != nil { 13 | fmt.Println(err) 14 | os.Exit(1) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /_examples/configuration/multi-environments/server.dev.yml: -------------------------------------------------------------------------------- 1 | ServerName: "my-iris-app" 2 | 3 | Host: 0.0.0.0 4 | Port: 8080 5 | EnableCompression: false 6 | AllowOrigin: "*" 7 | 8 | # Your development environment's 9 | # database connection configuration here... 10 | 11 | #### 12 | 13 | # Iris configuration. 14 | Iris: 15 | LogLevel: info 16 | EnableOptimizations: true 17 | RemoteAddrHeaders: 18 | - "X-Real-Ip" 19 | - "X-Forwarded-For" 20 | - "CF-Connecting-IP" 21 | - "True-Client-Ip" 22 | - "X-Appengine-Remote-Addr" 23 | -------------------------------------------------------------------------------- /_examples/configuration/multi-environments/server.yml: -------------------------------------------------------------------------------- 1 | Host: 0.0.0.0 2 | Port: 80 3 | EnableCompression: true 4 | AllowOrigin: "*" 5 | 6 | # Your production's database connection configuration here... 7 | 8 | #### 9 | 10 | # Iris configuration. 11 | Iris: 12 | LogLevel: info 13 | EnableOptimizations: true 14 | RemoteAddrHeaders: 15 | - "X-Real-Ip" 16 | - "X-Forwarded-For" 17 | - "CF-Connecting-IP" 18 | - "True-Client-Ip" 19 | - "X-Appengine-Remote-Addr" 20 | -------------------------------------------------------------------------------- /_examples/configuration/viper/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "app/config" 7 | 8 | "github.com/kataras/iris/v12" 9 | ) 10 | 11 | func main() { 12 | app := iris.New() 13 | app.Get("/", func(ctx iris.Context) { 14 | ctx.TextYAML(config.C) 15 | }) 16 | 17 | addr := fmt.Sprintf("%s:%d", config.C.Addr.Internal.IP, config.C.Addr.Internal.Plain) 18 | app.Listen(addr, iris.WithConfiguration(config.C.Iris)) 19 | } 20 | -------------------------------------------------------------------------------- /_examples/convert-handlers/nethttp/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | irisMiddleware := iris.FromStd(nativeTestMiddleware) 12 | app.Use(irisMiddleware) 13 | 14 | // Method GET: http://localhost:8080/ 15 | app.Get("/", func(ctx iris.Context) { 16 | ctx.HTML("Home") 17 | }) 18 | 19 | // Method GET: http://localhost:8080/ok 20 | app.Get("/ok", func(ctx iris.Context) { 21 | ctx.HTML("Hello world!") 22 | }) 23 | 24 | // http://localhost:8080 25 | // http://localhost:8080/ok 26 | app.Listen(":8080") 27 | } 28 | 29 | func nativeTestMiddleware(w http.ResponseWriter, r *http.Request) { 30 | println("Request path: " + r.URL.Path) 31 | } 32 | -------------------------------------------------------------------------------- /_examples/database/mongodb/.env: -------------------------------------------------------------------------------- 1 | PORT=8080 2 | DSN=mongodb://localhost:27017 -------------------------------------------------------------------------------- /_examples/database/mongodb/0_create_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/database/mongodb/0_create_movie.png -------------------------------------------------------------------------------- /_examples/database/mongodb/1_update_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/database/mongodb/1_update_movie.png -------------------------------------------------------------------------------- /_examples/database/mongodb/2_get_all_movies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/database/mongodb/2_get_all_movies.png -------------------------------------------------------------------------------- /_examples/database/mongodb/3_get_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/database/mongodb/3_get_movie.png -------------------------------------------------------------------------------- /_examples/database/mongodb/4_delete_movie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/database/mongodb/4_delete_movie.png -------------------------------------------------------------------------------- /_examples/database/mongodb/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker build -t myapp . 2 | # docker run --rm -it -p 8080:8080 myapp:latest 3 | FROM golang:latest AS builder 4 | RUN apt-get update 5 | ENV GO111MODULE=on \ 6 | CGO_ENABLED=0 \ 7 | GOOS=linux \ 8 | GOARCH=amd64 9 | WORKDIR /go/src/app 10 | COPY go.mod . 11 | RUN go mod download 12 | COPY . . 13 | RUN go install 14 | 15 | FROM scratch 16 | COPY --from=builder /go/bin/myapp . 17 | ENTRYPOINT ["./myapp"] -------------------------------------------------------------------------------- /_examples/database/mongodb/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | services: 4 | app: 5 | build: . 6 | environment: 7 | Port: 8080 8 | DSN: db:27017 9 | ports: 10 | - 8080:8080 11 | depends_on: 12 | - db 13 | db: 14 | image: mongo 15 | environment: 16 | MONGO_INITDB_DATABASE: store 17 | ports: 18 | - 27017:27017 19 | -------------------------------------------------------------------------------- /_examples/database/mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker build -t myapp . 2 | # docker run --rm -it -p 8080:8080 myapp:latest 3 | FROM golang:latest AS builder 4 | RUN apt-get update 5 | ENV GO111MODULE=on \ 6 | CGO_ENABLED=0 \ 7 | GOOS=linux \ 8 | GOARCH=amd64 9 | WORKDIR /go/src/app 10 | COPY go.mod . 11 | RUN go mod download 12 | COPY . . 13 | RUN go install 14 | 15 | FROM scratch 16 | COPY --from=builder /go/bin/myapp . 17 | ENTRYPOINT ["./myapp"] -------------------------------------------------------------------------------- /_examples/database/mysql/api/helper.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | const debug = true 10 | 11 | func debugf(format string, args ...interface{}) { 12 | if !debug { 13 | return 14 | } 15 | 16 | log.Printf(format, args...) 17 | } 18 | 19 | func writeInternalServerError(ctx iris.Context) { 20 | ctx.StopWithJSON(iris.StatusInternalServerError, newError(iris.StatusInternalServerError, ctx.Request().Method, ctx.Path(), "")) 21 | } 22 | 23 | func writeEntityNotFound(ctx iris.Context) { 24 | ctx.StopWithJSON(iris.StatusNotFound, newError(iris.StatusNotFound, ctx.Request().Method, ctx.Path(), "entity does not exist")) 25 | } 26 | -------------------------------------------------------------------------------- /_examples/database/mysql/api/middleware/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/database/mysql/api/middleware/.gitkeep -------------------------------------------------------------------------------- /_examples/database/mysql/migration/api_category/create_category.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "computer-internet", 3 | "position": 2, 4 | "image_url": "https://bp.pstatic.gr/public/dist/images/1mOPxYtw1k.webp" 5 | } -------------------------------------------------------------------------------- /_examples/database/mysql/migration/api_category/update_category.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 2, 3 | "position": 1, 4 | "title": "computers", 5 | "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Desktop_computer_clipart_-_Yellow_theme.svg/1200px-Desktop_computer_clipart_-_Yellow_theme.svg.png" 6 | } -------------------------------------------------------------------------------- /_examples/database/mysql/migration/api_category/update_partial_category.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "computers-technology" 3 | } -------------------------------------------------------------------------------- /_examples/database/mysql/migration/api_product/create_product.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "product-1", 3 | "category_id": 3, 4 | "image_url": "https://images.product1.png", 5 | "price": 42.42, 6 | "description": "a description for product-1" 7 | } -------------------------------------------------------------------------------- /_examples/database/mysql/migration/api_product/update_partial_product.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "product-19-new-title" 3 | } -------------------------------------------------------------------------------- /_examples/database/mysql/migration/api_product/update_product.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":19, 3 | "title": "product-19", 4 | "category_id": 3, 5 | "image_url": "https://images.product19.png", 6 | "price": 20, 7 | "description": "a description for product-19" 8 | } -------------------------------------------------------------------------------- /_examples/database/orm/gorm/REAMDE.md: -------------------------------------------------------------------------------- 1 | # GORM 2 | 3 | This example is pull by [#1275 PR](https://github.com/kataras/iris/pull/1275) by [@wuxiaoxiaoshen](https://github.com/wuxiaoxiaoshen). 4 | 5 | A more complete and real-world example can be found at the project created by [@snowlyg](https://github.com/snowlyg). 6 | -------------------------------------------------------------------------------- /_examples/database/orm/reform/models/person.go: -------------------------------------------------------------------------------- 1 | //go:generate reform 2 | package models 3 | 4 | import "time" 5 | 6 | //reform:people 7 | type Person struct { 8 | ID int32 `reform:"id,pk" json:"id"` 9 | Name string `reform:"name" json:"name"` 10 | Email *string `reform:"email" json:"email"` 11 | CreatedAt time.Time `reform:"created_at" json:"created_at"` 12 | UpdatedAt *time.Time `reform:"updated_at" json:"updated_at"` 13 | } 14 | -------------------------------------------------------------------------------- /_examples/dependency-injection/overview/datamodels/movie.go: -------------------------------------------------------------------------------- 1 | // file: datamodels/movie.go 2 | 3 | package datamodels 4 | 5 | // Movie is our sample data structure. 6 | // Keep note that the tags for public-use (for our web app) 7 | // should be kept in other file like "web/viewmodels/movie.go" 8 | // which could wrap by embedding the datamodels.Movie or 9 | // declare new fields instead butwe will use this datamodel 10 | // as the only one Movie model in our application, 11 | // for the sake of simplicty. 12 | type Movie struct { 13 | ID uint64 `json:"id"` 14 | Name string `json:"name"` 15 | Year int `json:"year"` 16 | Genre string `json:"genre"` 17 | Poster string `json:"poster"` 18 | } 19 | -------------------------------------------------------------------------------- /_examples/dependency-injection/overview/web/middleware/basicauth.go: -------------------------------------------------------------------------------- 1 | // file: web/middleware/basicauth.go 2 | 3 | package middleware 4 | 5 | import "github.com/kataras/iris/v12/middleware/basicauth" 6 | 7 | // BasicAuth middleware sample. 8 | var BasicAuth = basicauth.Default(map[string]string{ 9 | "admin": "password", 10 | }) 11 | -------------------------------------------------------------------------------- /_examples/dependency-injection/overview/web/views/hello/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{.Title}} - My App 6 | 7 | 8 | 9 |

{{.MyMessage}}

10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/dependency-injection/overview/web/views/hello/name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{.}}' Portfolio - My App 6 | 7 | 8 | 9 |

Hello {{.}}

10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/dependency-injection/sessions/routes/index.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12/sessions" 7 | ) 8 | 9 | // Index will increment a simple int version based on the visits that this user/session did. 10 | func Index(session *sessions.Session) string { 11 | // it increments a "visits" value of integer by one, 12 | // if the entry with key 'visits' doesn't exist it will create it for you. 13 | visits := session.Increment("visits", 1) 14 | 15 | // write the current, updated visits. 16 | return fmt.Sprintf("%d visit(s) from my current session", visits) 17 | } 18 | -------------------------------------------------------------------------------- /_examples/dropzonejs/folder_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/dropzonejs/folder_structure.png -------------------------------------------------------------------------------- /_examples/dropzonejs/meta.yml: -------------------------------------------------------------------------------- 1 | Name: DropzoneJS 2 | Articles: 3 | - Title: How to build a file upload form using DropzoneJS and Go 4 | Source: https://medium.com/hackernoon/how-to-build-a-file-upload-form-using-dropzonejs-and-go-8fb9f258a991 5 | Author: https://twitter.com/@kataras 6 | - Title: How to display existing files on server using DropzoneJS and Go 7 | Source: https://medium.com/@kataras/how-to-display-existing-files-on-server-using-dropzonejs-and-go-53e24b57ba19 8 | Author: https://twitter.com/@kataras -------------------------------------------------------------------------------- /_examples/dropzonejs/no_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/dropzonejs/no_files.png -------------------------------------------------------------------------------- /_examples/dropzonejs/with_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/dropzonejs/with_files.png -------------------------------------------------------------------------------- /_examples/file-server/basic/assets.system/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/basic/assets.system/test.txt: -------------------------------------------------------------------------------- 1 | main_test.go#TestHandleDirDot -------------------------------------------------------------------------------- /_examples/file-server/basic/assets/app2/app22/just_a_text_no_index.txt: -------------------------------------------------------------------------------- 1 | just a text. -------------------------------------------------------------------------------- /_examples/file-server/basic/assets/app2/app2app3/index.html: -------------------------------------------------------------------------------- 1 |

Hello App2App3 index

-------------------------------------------------------------------------------- /_examples/file-server/basic/assets/app2/index.html: -------------------------------------------------------------------------------- 1 |

Hello App2 index

-------------------------------------------------------------------------------- /_examples/file-server/basic/assets/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/basic/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/basic/assets/favicon.ico -------------------------------------------------------------------------------- /_examples/file-server/basic/assets/index.html: -------------------------------------------------------------------------------- 1 |

Hello index

-------------------------------------------------------------------------------- /_examples/file-server/basic/assets/js/main.js: -------------------------------------------------------------------------------- 1 | console.log("example"); -------------------------------------------------------------------------------- /_examples/file-server/embedding-files-into-app-bindata/assets/css/main.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: sans-serif; 3 | -webkit-text-size-adjust: 100%; 4 | -ms-text-size-adjust: 100% 5 | } -------------------------------------------------------------------------------- /_examples/file-server/embedding-files-into-app-bindata/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/embedding-files-into-app-bindata/assets/favicon.ico -------------------------------------------------------------------------------- /_examples/file-server/embedding-files-into-app-bindata/assets/js/main.js: -------------------------------------------------------------------------------- 1 | console.log("example"); -------------------------------------------------------------------------------- /_examples/file-server/embedding-files-into-app/assets/css/main.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: sans-serif; 3 | -webkit-text-size-adjust: 100%; 4 | -ms-text-size-adjust: 100% 5 | } -------------------------------------------------------------------------------- /_examples/file-server/embedding-files-into-app/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/embedding-files-into-app/assets/favicon.ico -------------------------------------------------------------------------------- /_examples/file-server/embedding-files-into-app/assets/js/main.js: -------------------------------------------------------------------------------- 1 | console.log("example"); -------------------------------------------------------------------------------- /_examples/file-server/favicon/static/favicons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/favicon/static/favicons/favicon.ico -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/app2app3/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: blue; 3 | } -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/app2app3/dirs/dir1/text.txt: -------------------------------------------------------------------------------- 1 | app2/app2app3/dirs/dir1/text.txt -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/app2app3/dirs/dir2/text.txt: -------------------------------------------------------------------------------- 1 | app2/app2app3/dirs/dir2/text.txt -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/app2app3/dirs/text.txt: -------------------------------------------------------------------------------- 1 | app2/app2app3/dirs/text.txt -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/app2app3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | App2App3 9 | 10 | 11 | 12 |

Hello App2App3 index

13 | 14 | 15 | -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/index.html: -------------------------------------------------------------------------------- 1 |

Hello App2 index

-------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/app2/mydir/text.txt: -------------------------------------------------------------------------------- 1 | just a text. -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/http2push/assets/favicon.ico -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | File Server 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /_examples/file-server/http2push/assets/js/main.js: -------------------------------------------------------------------------------- 1 | console.log("example"); 2 | 3 | function onClick() { 4 | window.alert("button clicked"); 5 | } -------------------------------------------------------------------------------- /_examples/file-server/send-files/files/first.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/send-files/files/first.zip -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/basic/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/kataras/iris/v12" 4 | 5 | func newApp() *iris.Application { 6 | app := iris.New() 7 | 8 | app.HandleDir("/", iris.Dir("./public"), iris.DirOptions{ 9 | IndexName: "index.html", 10 | SPA: true, 11 | }) 12 | 13 | return app 14 | } 15 | 16 | func main() { 17 | app := newApp() 18 | 19 | // http://localhost:8080 20 | // http://localhost:8080/about 21 | // http://localhost:8080/a_notfound 22 | app.Listen(":8080") 23 | } 24 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/basic/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Iris SPA Router Example 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/basic/public/index.js: -------------------------------------------------------------------------------- 1 | const NotFound = { template: '

Page not found

' } 2 | const Home = { template: '

home page

' } 3 | const About = { template: '

about page

' } 4 | 5 | const routes = { 6 | '/': Home, 7 | '/about': About 8 | } 9 | 10 | const app = new Vue({ 11 | el: '#app', 12 | data: { 13 | currentRoute: window.location.pathname 14 | }, 15 | computed: { 16 | ViewComponent () { 17 | return routes[this.currentRoute] || NotFound 18 | } 19 | }, 20 | render (h) { return h(this.ViewComponent) } 21 | }) 22 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application-with-other-routes/public/app.js: -------------------------------------------------------------------------------- 1 | window.alert("app.js loaded from static page of \"/"); -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application-with-other-routes/public/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application-with-other-routes/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello from static page 5 | 6 | 7 | 8 |

Hello from index.html

9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application/data/public/app.js: -------------------------------------------------------------------------------- 1 | window.alert("app.js loaded from \"/"); -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application/data/public/app2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | App 2 5 | 6 | 7 | 8 |

(Static HTML Page) Hello from app2/index.html

9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application/data/public/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/single-page-application/embedded-single-page-application/data/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ .Page.Title }} 5 | 6 | 7 | 8 |

(Template) Hello from views/index.html

9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /_examples/file-server/spa-vue-router/frontend/css/page.css: -------------------------------------------------------------------------------- 1 | .router-link-active { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/app2/app22/just_a_text_no_index.txt: -------------------------------------------------------------------------------- 1 | just a text. -------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/app2/app2app3/index.html: -------------------------------------------------------------------------------- 1 |

Hello App2App3 index

-------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/app2/index.html: -------------------------------------------------------------------------------- 1 |

Hello App2 index

-------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/subdomain/assets/favicon.ico -------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/index.html: -------------------------------------------------------------------------------- 1 |

Hello index

-------------------------------------------------------------------------------- /_examples/file-server/subdomain/assets/js/jquery-2.1.1.js: -------------------------------------------------------------------------------- 1 | console.log("example"); -------------------------------------------------------------------------------- /_examples/file-server/subdomain/hosts: -------------------------------------------------------------------------------- 1 | 127.0.0.1 examle.com 2 | 127.0.0.1 v1.examle.com -------------------------------------------------------------------------------- /_examples/file-server/subdomain/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | const ( 8 | addr = "example.com:80" 9 | subdomain = "v1" 10 | ) 11 | 12 | func newApp() *iris.Application { 13 | app := iris.New() 14 | app.Favicon("./assets/favicon.ico") 15 | 16 | v1 := app.Subdomain(subdomain) 17 | v1.HandleDir("/", iris.Dir("./assets")) 18 | 19 | // http://v1.example.com 20 | // http://v1.example.com/css/main.css 21 | // http://v1.example.com/js/jquery-2.1.1.js 22 | // http://v1.example.com/favicon.ico 23 | return app 24 | } 25 | 26 | func main() { 27 | app := newApp() 28 | app.Listen(addr) 29 | } 30 | -------------------------------------------------------------------------------- /_examples/file-server/upload-file/templates/upload_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Upload file 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /_examples/file-server/upload-file/uploads/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/upload-file/uploads/.gitkeep -------------------------------------------------------------------------------- /_examples/file-server/upload-files/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/kataras/iris/v12/httptest" 8 | ) 9 | 10 | func TestUploadFiles(t *testing.T) { 11 | app := newApp() 12 | e := httptest.New(t, app) 13 | 14 | // upload the file itself. 15 | fh, err := os.Open("main.go") 16 | if err != nil { 17 | t.Fatal(err) 18 | } 19 | defer fh.Close() 20 | 21 | e.POST("/upload").WithMultipart().WithFile("files", "main.go", fh). 22 | Expect().Status(httptest.StatusOK) 23 | 24 | f, err := os.Open("uploads/main.go") 25 | if err != nil { 26 | t.Fatalf("expected file to get actually uploaded on the system directory but: %v", err) 27 | } 28 | f.Close() 29 | 30 | os.Remove(f.Name()) 31 | } 32 | -------------------------------------------------------------------------------- /_examples/file-server/upload-files/templates/upload_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Upload file 4 | 5 | 6 |
8 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/file-server/upload-files/uploads/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/upload-files/uploads/.gitkeep -------------------------------------------------------------------------------- /_examples/file-server/webdav/newdir/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/file-server/webdav/newdir/.gitkeep -------------------------------------------------------------------------------- /_examples/file-server/webdav/test.txt: -------------------------------------------------------------------------------- 1 | Hello, world! 2 | -------------------------------------------------------------------------------- /_examples/graphql/schema-first/graph/resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | import "github.com/iris-contrib/outerbanks-api/graph/model" 4 | 5 | // This file will not be regenerated automatically. 6 | // 7 | // It serves as dependency injection for your app, add any dependencies you require here. 8 | 9 | type Resolver struct { 10 | CharacterStore map[string]model.Character 11 | } 12 | -------------------------------------------------------------------------------- /_examples/graphql/schema-first/graph/schema.graphqls: -------------------------------------------------------------------------------- 1 | # GraphQL schema example 2 | # 3 | # https://gqlgen.com/getting-started/ 4 | 5 | enum CliqueType { 6 | "People who are elite with parents having money" 7 | KOOKS 8 | "People who desperate to move up the social ladder to become new versions of themselves and establish new beginnings" 9 | POGUES 10 | } 11 | 12 | type Character { 13 | id: ID! 14 | name: String! 15 | isHero: Boolean! 16 | cliqueType: CliqueType! 17 | } 18 | 19 | input CharacterInput { 20 | name: String! 21 | id: String 22 | isHero: Boolean 23 | cliqueType: CliqueType! 24 | } 25 | 26 | type Mutation { 27 | upsertCharacter(input: CharacterInput!): Character! 28 | } 29 | 30 | type Query { 31 | character(id:ID!): Character 32 | characters(cliqueType:CliqueType!): [Character!] 33 | } -------------------------------------------------------------------------------- /_examples/graphql/schema-first/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | package tools 5 | 6 | import _ "github.com/99designs/gqlgen" 7 | -------------------------------------------------------------------------------- /_examples/http-client/weatherapi/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/kataras/iris/v12/_examples/http-client/weatherapi/client" 8 | ) 9 | 10 | func main() { 11 | c := client.NewClient(client.Options{ 12 | APIKey: "{YOUR_API_KEY_HERE}", 13 | }) 14 | 15 | resp, err := c.GetCurrentByCity(context.Background(), "Xanthi/GR") 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | fmt.Printf("Temp: %.2f(C), %.2f(F)\n", resp.Current.TempC, resp.Current.TempF) 21 | } 22 | -------------------------------------------------------------------------------- /_examples/http-server/custom-listener/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | 12 | app.Get("/", func(ctx iris.Context) { 13 | ctx.Writef("Hello from the server") 14 | }) 15 | 16 | app.Get("/mypath", func(ctx iris.Context) { 17 | ctx.Writef("Hello from %s", ctx.Path()) 18 | }) 19 | 20 | // create any custom tcp listener, unix sock file or tls tcp listener. 21 | l, err := net.Listen("tcp4", ":8080") 22 | if err != nil { 23 | panic(err) 24 | } 25 | 26 | // use of the custom listener 27 | app.Run(iris.Listener(l)) 28 | } 29 | -------------------------------------------------------------------------------- /_examples/http-server/http3-quic/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | 6 | "github.com/quic-go/quic-go/http3" 7 | ) 8 | 9 | /* 10 | $ go get github.com/quic-go/quic-go@master 11 | */ 12 | 13 | func main() { 14 | app := iris.New() 15 | 16 | app.Get("/", func(ctx iris.Context) { 17 | ctx.Writef("Hello from Index") 18 | }) 19 | 20 | // app.Configure(iris.WithOptimizations, or any other core config here) 21 | // app.Build() 22 | // http3.ListenAndServe(":443", "./localhost.cert", "./localhost.key", app) 23 | // OR: 24 | app.Run(iris.Raw(func() error { 25 | return http3.ListenAndServe(":443", "./localhost.cert", "./localhost.key", app) 26 | })) 27 | } 28 | -------------------------------------------------------------------------------- /_examples/http-server/listen-addr/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/kataras/iris/v12" 4 | 5 | func main() { 6 | app := iris.New() 7 | 8 | app.Get("/", func(ctx iris.Context) { 9 | ctx.HTML("

Hello World!

") 10 | }) 11 | 12 | // http://localhost:8080 13 | // Identical to: app.Run(iris.Addr(":8080")) 14 | 15 | app.Listen(":8080") 16 | // To listen using keep alive tcp connection listener, 17 | // set the KeepAlive duration configuration instead: 18 | // app.Listen(":8080", iris.WithKeepAlive(3*time.Minute)) 19 | } 20 | -------------------------------------------------------------------------------- /_examples/http-server/listen-addr/omit-server-errors/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func main() { 8 | app := iris.New() 9 | 10 | app.Get("/", func(ctx iris.Context) { 11 | ctx.HTML("

Hello World!

") 12 | }) 13 | 14 | err := app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed)) 15 | if err != nil { 16 | // do something 17 | } 18 | // same as: 19 | // err := app.Listen(":8080") 20 | // import "errors" 21 | // if errors.Is(err, iris.ErrServerClosed) { 22 | // [...] 23 | // } 24 | } 25 | -------------------------------------------------------------------------------- /_examples/http-server/listen-unix/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | "github.com/kataras/iris/v12/core/netutil" 6 | ) 7 | 8 | func main() { 9 | app := iris.New() 10 | 11 | l, err := netutil.UNIX("/tmpl/srv.sock", 0666) // see its code to see how you can manually create a new file listener, it's easy. 12 | if err != nil { 13 | panic(err) 14 | } 15 | 16 | app.Run(iris.Listener(l)) 17 | } 18 | -------------------------------------------------------------------------------- /_examples/http-server/socket-sharding/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | startup := time.Now() 11 | 12 | app := iris.New() 13 | app.Get("/", func(ctx iris.Context) { 14 | s := startup.Format(ctx.Application().ConfigurationReadOnly().GetTimeFormat()) 15 | ctx.Writef("This server started at: %s\n", s) 16 | }) 17 | 18 | // This option allows linear scaling server performance on multi-CPU servers. 19 | // See https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/ for details. 20 | app.Listen(":8080", iris.WithSocketSharding) 21 | } 22 | -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/el-GR/locale_el-GR.ini: -------------------------------------------------------------------------------- 1 | hi = γεια, %s 2 | userProfilePublicDescription = περιγραφή προφιλ -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/el-GR/locale_multi_first_el-GR.yml: -------------------------------------------------------------------------------- 1 | key1: "αυτό είναι μια τιμή από το πρώτο αρχείο: locale_multi_first" -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/el-GR/locale_multi_second_el-GR.ini: -------------------------------------------------------------------------------- 1 | key2 = αυτό είναι μια τιμή από το δεύτερο αρχείο μετάφρασης: locale_multi_second -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/en-US/locale_en-US.ini: -------------------------------------------------------------------------------- 1 | hi = hello, %s 2 | userProfilePublicDescription = profile description -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/en-US/locale_multi_first_en-US.yml: -------------------------------------------------------------------------------- 1 | key1: "this is a value from the first file: locale_multi_first" -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/en-US/locale_multi_second_en-US.ini: -------------------------------------------------------------------------------- 1 | key2 = this is a value from the second file: locale_multi_second -------------------------------------------------------------------------------- /_examples/i18n/basic/locales/zh-CN/locale_zh-CN.ini: -------------------------------------------------------------------------------- 1 | hi = 您好,%s 2 | userProfilePublicDescription = 个人资料描述 -------------------------------------------------------------------------------- /_examples/i18n/basic/views/index.html: -------------------------------------------------------------------------------- 1 |

Test translate current locale template function [dynamic] ("word", arguments...)
call .tr "hi" "iris"

2 | 3 | {{call .tr "hi" "iris"}} 4 | 5 |
6 | 7 |

Test translate of any language template function [static] ("language", "word", arguments...)
tr "zh-CN" "hi" "iris"

8 | 9 | {{tr "zh-CN" "hi" "iris"}} 10 | 11 |

Test HTML link ("word", arguments...)
call .trUnsafe "trUnsafe" "userProfilePublicDescription" "https://iris-go.com"

12 | 13 | {{call .trUnsafe "userProfilePublicDescription" "https://iris-go.com"}} -------------------------------------------------------------------------------- /_examples/i18n/plurals/locales/en-US/1648.ini: -------------------------------------------------------------------------------- 1 | [message] 2 | Encrypted = Encrypted 3 | Message = Message 4 | EncryptedMessage = {{tr "message.Encrypted"}} {{tr "message.Message"}} 5 | HostResult = Store {{tr "message.EncryptedMessage"}} Online -------------------------------------------------------------------------------- /_examples/i18n/template-embedded/embedded/locales/el-GR/other.ini: -------------------------------------------------------------------------------- 1 | [nav] 2 | User = Λογαριασμός 3 | 4 | [debug] 5 | Title = Μενού προγραμματιστή 6 | AccessLog = Πρόσβαση στο αρχείο καταγραφής 7 | AccessLogClear = Καθαρισμός {{ tr "debug.AccessLog" }} 8 | 9 | [user.connections] 10 | Title = {{ tr "nav.User" }} Συνδέσεις -------------------------------------------------------------------------------- /_examples/i18n/template-embedded/embedded/locales/el-GR/user.ini: -------------------------------------------------------------------------------- 1 | [forms] 2 | member = μέλος 3 | register = Γίνε {{ uppercase (tr "forms.member") }} 4 | registered = εγγεγραμμένοι -------------------------------------------------------------------------------- /_examples/i18n/template-embedded/embedded/locales/en-US/other.ini: -------------------------------------------------------------------------------- 1 | # just an example of some more nested keys, 2 | # see /other endpoint. 3 | [nav] 4 | User = Account 5 | 6 | [debug] 7 | Title = Developer Menu 8 | AccessLog = Access Log 9 | AccessLogClear = Clear {{ tr "debug.AccessLog" }} 10 | 11 | [user.connections] 12 | Title = {{ tr "nav.User" }} Connections -------------------------------------------------------------------------------- /_examples/i18n/template-embedded/embedded/locales/en-US/user.ini: -------------------------------------------------------------------------------- 1 | [forms] 2 | member = member 3 | register = Become a {{ uppercase (tr "forms.member") }} 4 | registered = registered -------------------------------------------------------------------------------- /_examples/i18n/template-embedded/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestI18nLoaderFuncMap(t *testing.T) { 10 | app := newApp() 11 | 12 | e := httptest.New(t, app) 13 | e.GET("/").Expect().Status(httptest.StatusOK). 14 | Body().IsEqual("Become a MEMBER") 15 | e.GET("/title").Expect().Status(httptest.StatusOK). 16 | Body().IsEqual("Account Connections") 17 | e.GET("/").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK). 18 | Body().IsEqual("Γίνε ΜΈΛΟΣ") 19 | e.GET("/title").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK). 20 | Body().IsEqual("Λογαριασμός Συνδέσεις") 21 | } 22 | -------------------------------------------------------------------------------- /_examples/i18n/template/locales/el-GR/other.ini: -------------------------------------------------------------------------------- 1 | [nav] 2 | User = Λογαριασμός 3 | 4 | [debug] 5 | Title = Μενού προγραμματιστή 6 | AccessLog = Πρόσβαση στο αρχείο καταγραφής 7 | AccessLogClear = Καθαρισμός {{tr "debug.AccessLog"}} 8 | 9 | [user.connections] 10 | Title = {{tr "nav.User"}} Συνδέσεις -------------------------------------------------------------------------------- /_examples/i18n/template/locales/el-GR/user.ini: -------------------------------------------------------------------------------- 1 | [forms] 2 | member = μέλος 3 | register = Γίνε {{uppercase (tr "forms.member") }} 4 | registered = εγγεγραμμένοι -------------------------------------------------------------------------------- /_examples/i18n/template/locales/en-US/other.ini: -------------------------------------------------------------------------------- 1 | # just an example of some more nested keys, 2 | # see /other endpoint. 3 | [nav] 4 | User = Account 5 | 6 | [debug] 7 | Title = Developer Menu 8 | AccessLog = Access Log 9 | AccessLogClear = Clear {{tr "debug.AccessLog"}} 10 | 11 | [user.connections] 12 | Title = {{tr "nav.User"}} Connections -------------------------------------------------------------------------------- /_examples/i18n/template/locales/en-US/user.ini: -------------------------------------------------------------------------------- 1 | [forms] 2 | member = member 3 | register = Become a {{uppercase (tr "forms.member") }} 4 | registered = registered -------------------------------------------------------------------------------- /_examples/i18n/template/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestI18nLoaderFuncMap(t *testing.T) { 10 | app := newApp() 11 | 12 | e := httptest.New(t, app) 13 | e.GET("/").Expect().Status(httptest.StatusOK). 14 | Body().IsEqual("Become a MEMBER") 15 | e.GET("/title").Expect().Status(httptest.StatusOK). 16 | Body().IsEqual("Account Connections") 17 | e.GET("/").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK). 18 | Body().IsEqual("Γίνε ΜΈΛΟΣ") 19 | e.GET("/title").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK). 20 | Body().IsEqual("Λογαριασμός Συνδέσεις") 21 | } 22 | -------------------------------------------------------------------------------- /_examples/kafka-api/0_docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/kafka-api/0_docs.png -------------------------------------------------------------------------------- /_examples/kafka-api/1_create_topic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/kafka-api/1_create_topic.png -------------------------------------------------------------------------------- /_examples/kafka-api/2_list_topics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/kafka-api/2_list_topics.png -------------------------------------------------------------------------------- /_examples/kafka-api/3_store_to_topic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/kafka-api/3_store_to_topic.png -------------------------------------------------------------------------------- /_examples/kafka-api/4_retrieve_from_topic_real_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/kafka-api/4_retrieve_from_topic_real_time.png -------------------------------------------------------------------------------- /_examples/kafka-api/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker build -t myapp . 2 | # docker run --rm -it -p 8080:8080 myapp:latest 3 | FROM golang:latest AS builder 4 | RUN apt-get update 5 | ENV GO111MODULE=on \ 6 | CGO_ENABLED=0 \ 7 | GOOS=linux \ 8 | GOARCH=amd64 9 | WORKDIR /go/src/app 10 | COPY go.mod . 11 | RUN go mod download 12 | COPY . . 13 | RUN go install 14 | 15 | FROM scratch 16 | COPY --from=builder /go/bin/myapp . 17 | ENTRYPOINT ["./myapp"] -------------------------------------------------------------------------------- /_examples/logging/request-logger/accesslog-csv/access_log.csv.sample: -------------------------------------------------------------------------------- 1 | Timestamp,Latency,Code,Method,Path,IP,Req Values,In,Out,Request,Response 2 | 1599996265254,0s,200,GET,/,::1,a=1 b=2,0,5,,Index 3 | 1599996266138,0s,200,GET,/,::1,sleep=32ms,0,5,,Index 4 | 1599996266778,1s,200,GET,/,::1,sleep=1s,0,5,,Index 5 | 1599996267780,1s,200,GET,/,::1,sleep=1s,0,5,,Index 6 | -------------------------------------------------------------------------------- /_examples/logging/request-logger/accesslog-csv/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/kataras/iris/v12" 7 | "github.com/kataras/iris/v12/middleware/accesslog" 8 | ) 9 | 10 | func main() { 11 | app := iris.New() 12 | ac := accesslog.File("access_log.csv") 13 | ac.ResponseBody = true 14 | ac.LatencyRound = time.Second 15 | ac.SetFormatter(&accesslog.CSV{ 16 | Header: true, 17 | // DateScript: "FROM_UNIX", 18 | }) 19 | 20 | app.UseRouter(ac.Handler) 21 | app.Get("/", index) 22 | 23 | app.Listen(":8080") 24 | } 25 | 26 | func index(ctx iris.Context) { 27 | if sleepDur := ctx.URLParam("sleep"); sleepDur != "" { 28 | if d, err := time.ParseDuration(sleepDur); err == nil { 29 | time.Sleep(d) 30 | } 31 | } 32 | 33 | ctx.WriteString("Index") 34 | } 35 | -------------------------------------------------------------------------------- /_examples/logging/request-logger/accesslog-simple/access.log.sample: -------------------------------------------------------------------------------- 1 | {"timestamp":1599993744664,"latency":0,"code":404,"method":"GET","path":"/favicon.ico","ip":"::1","request":"","bytes_sent":9} 2 | {"timestamp":1599993774018,"latency":0,"code":200,"method":"GET","path":"/","ip":"::1","query":[{"key":"a","value":"1"},{"key":"b","value":"2"}],"request":"","bytes_sent":2} 3 | -------------------------------------------------------------------------------- /_examples/logging/request-logger/accesslog/public/index.html: -------------------------------------------------------------------------------- 1 |

Hello index

-------------------------------------------------------------------------------- /_examples/mvc/error-handler-custom-result/views/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Client Error Page 7 | 8 | 9 |

{{.Code}}

10 |

{{.Message}}

11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/error-handler-custom-result/views/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Server Error Page 7 | 8 | 9 |

{{.Code}}

10 |

{{.Message}}

11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/error-handler-hijack/views/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Client Error Page 7 | 8 | 9 |

{{.Code}}

10 |

{{.Message}}

11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/error-handler-hijack/views/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Server Error Page 7 | 8 | 9 |

{{.Code}}

10 |

{{.Message}}

11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/error-handler-http/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestControllerHandleHTTPError(t *testing.T) { 10 | const ( 11 | expectedIndex = "Hello!" 12 | expectedNotFound = "

Not Found Custom Page Rendered through Controller's HandleHTTPError

" 13 | ) 14 | 15 | app := newApp() 16 | 17 | e := httptest.New(t, app) 18 | e.GET("/").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedIndex) 19 | e.GET("/a_notefound").Expect().Status(httptest.StatusNotFound).ContentType("text/html").Body().IsEqual(expectedNotFound) 20 | } 21 | -------------------------------------------------------------------------------- /_examples/mvc/error-handler-http/views/404.html: -------------------------------------------------------------------------------- 1 |

Not Found Custom Page Rendered through Controller's HandleHTTPError

-------------------------------------------------------------------------------- /_examples/mvc/error-handler-http/views/500.html: -------------------------------------------------------------------------------- 1 |

Internal Server Err

-------------------------------------------------------------------------------- /_examples/mvc/error-handler-http/views/unexpected-error.html: -------------------------------------------------------------------------------- 1 |

Unexpected Error

-------------------------------------------------------------------------------- /_examples/mvc/error-handler-preflight/views/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Client Error Page 7 | 8 | 9 |

{{.Code}}

10 |

{{.Message}}

11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/error-handler-preflight/views/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Server Error Page 7 | 8 | 9 |

{{.Code}}

10 |

{{.Message}}

11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/grpc-compatible/README.md: -------------------------------------------------------------------------------- 1 | # gRPC Iris Example 2 | 3 | ## Generate TLS Keys 4 | 5 | ```sh 6 | $ openssl genrsa -out server.key 2048 7 | $ openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650 8 | ``` 9 | 10 | ## Install the protoc Go plugin 11 | 12 | ```sh 13 | $ go get -u github.com/golang/protobuf/protoc-gen-go 14 | ``` 15 | 16 | ## Generate proto 17 | 18 | ```sh 19 | $ protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld 20 | ``` 21 | -------------------------------------------------------------------------------- /_examples/mvc/grpc-compatible/helloworld/README.md: -------------------------------------------------------------------------------- 1 | # Helloworld gRPC Example 2 | 3 | https://github.com/grpc/grpc-go/tree/master/examples/helloworld -------------------------------------------------------------------------------- /_examples/mvc/grpc-compatible/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestGRPCCompatible(t *testing.T) { 10 | app := newApp() 11 | 12 | e := httptest.New(t, app) 13 | e.POST("/helloworld.Greeter/SayHello").WithJSON(map[string]string{"name": "makis"}).Expect(). 14 | Status(httptest.StatusOK). 15 | JSON().IsEqual(map[string]string{"message": "Hello makis"}) 16 | } 17 | -------------------------------------------------------------------------------- /_examples/mvc/hello-world/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestMVCHelloWorld(t *testing.T) { 10 | e := httptest.New(t, newApp()) 11 | 12 | e.GET("/").Expect().Status(httptest.StatusOK). 13 | ContentType("text/html", "utf-8").Body().IsEqual("

Welcome

") 14 | 15 | e.GET("/ping").Expect().Status(httptest.StatusOK). 16 | Body().IsEqual("pong") 17 | 18 | e.GET("/hello").Expect().Status(httptest.StatusOK). 19 | JSON().Object().Value("message").Equal("Hello Iris!") 20 | 21 | e.GET("/custom_path").Expect().Status(httptest.StatusOK). 22 | Body().IsEqual("hello from the custom handler without following the naming guide") 23 | } 24 | -------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/folder_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/mvc/login-mvc-single-responsibility/folder_structure.png -------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/views/shared/error.html: -------------------------------------------------------------------------------- 1 |

Error.

2 |

An error occurred while processing your request.

3 | 4 |

{{.Message}}

-------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/views/shared/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{.Title}} 5 | 6 | 7 | 8 | 9 | {{ yield . }} 10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/views/user/login.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
-------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/views/user/me.html: -------------------------------------------------------------------------------- 1 |

2 | Welcome back {{.User.Firstname}}! 3 |

-------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/views/user/notfound.html: -------------------------------------------------------------------------------- 1 |

2 | User with ID {{.ID}} does not exist. 3 |

-------------------------------------------------------------------------------- /_examples/mvc/login-mvc-single-responsibility/views/user/register.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
-------------------------------------------------------------------------------- /_examples/mvc/login/folder_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/mvc/login/folder_structure.png -------------------------------------------------------------------------------- /_examples/mvc/login/web/middleware/basicauth.go: -------------------------------------------------------------------------------- 1 | // file: middleware/basicauth.go 2 | 3 | package middleware 4 | 5 | import "github.com/kataras/iris/v12/middleware/basicauth" 6 | 7 | // BasicAuth middleware sample. 8 | var BasicAuth = basicauth.Default(map[string]string{ 9 | "admin": "password", 10 | }) 11 | -------------------------------------------------------------------------------- /_examples/mvc/login/web/views/shared/error.html: -------------------------------------------------------------------------------- 1 |

Error.

2 |

An error occurred while processing your request.

3 | 4 |

{{.Message}}

5 | 6 | -------------------------------------------------------------------------------- /_examples/mvc/login/web/views/shared/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{.Title}} 5 | 6 | 7 | 8 | 9 | {{ yield . }} 10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/login/web/views/user/login.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
-------------------------------------------------------------------------------- /_examples/mvc/login/web/views/user/me.html: -------------------------------------------------------------------------------- 1 |

2 | Welcome back {{.User.Firstname}}! 3 |

-------------------------------------------------------------------------------- /_examples/mvc/login/web/views/user/register.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
-------------------------------------------------------------------------------- /_examples/mvc/overview/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker build -t app . 2 | # docker run --rm -it -p 8080:8080 app:latest 3 | FROM golang:latest AS builder 4 | RUN apt-get update 5 | ENV GO111MODULE=on \ 6 | CGO_ENABLED=0 \ 7 | GOOS=linux \ 8 | GOARCH=amd64 9 | WORKDIR /go/src/app 10 | COPY go.mod . 11 | RUN go mod download 12 | COPY . . 13 | RUN go install 14 | 15 | FROM scratch 16 | COPY --from=builder /go/bin/app . 17 | ENTRYPOINT ["./app"] -------------------------------------------------------------------------------- /_examples/mvc/overview/controller/greet_controller.go: -------------------------------------------------------------------------------- 1 | package controller 2 | 3 | import ( 4 | "app/model" 5 | "app/service" 6 | ) 7 | 8 | // GreetController handles the index. 9 | type GreetController struct { 10 | Service service.GreetService 11 | // Ctx iris.Context 12 | } 13 | 14 | // Get serves [GET] /. 15 | // Query: name 16 | func (c *GreetController) Get(req model.Request) (model.Response, error) { 17 | message, err := c.Service.Say(req.Name) 18 | if err != nil { 19 | return model.Response{}, err 20 | } 21 | 22 | return model.Response{Message: message}, nil 23 | } 24 | -------------------------------------------------------------------------------- /_examples/mvc/overview/database/database.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import "app/environment" 4 | 5 | // DB example database interface. 6 | type DB interface { 7 | Exec(q string) error 8 | } 9 | 10 | // NewDB returns a database based on "env". 11 | func NewDB(env environment.Env) DB { 12 | switch env { 13 | case environment.PROD: 14 | return &mysql{} 15 | case environment.DEV: 16 | return &sqlite{} 17 | default: 18 | panic("unknown environment") 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /_examples/mvc/overview/database/mysql.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import "fmt" 4 | 5 | type mysql struct{} 6 | 7 | func (db *mysql) Exec(q string) error { 8 | // simulate an error response. 9 | return fmt.Errorf("mysql: not implemented <%s>", q) 10 | } 11 | -------------------------------------------------------------------------------- /_examples/mvc/overview/database/sqlite.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | type sqlite struct{} 4 | 5 | func (db *sqlite) Exec(q string) error { return nil } 6 | -------------------------------------------------------------------------------- /_examples/mvc/overview/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.1' 2 | 3 | services: 4 | app: 5 | build: . 6 | ports: 7 | - 8080:8080 8 | environment: 9 | PORT: 8080 10 | ENVIRONMENT: development 11 | restart: on-failure 12 | healthcheck: 13 | test: ["CMD", "curl", "-f", "http://localhost:8080/ping"] 14 | interval: 30s 15 | timeout: 10s 16 | retries: 5 17 | -------------------------------------------------------------------------------- /_examples/mvc/overview/model/request.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // Request example incoming request. 4 | type Request struct { 5 | Name string `json:"name" url:"name"` 6 | } 7 | -------------------------------------------------------------------------------- /_examples/mvc/overview/model/response.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // Response example server's response. 4 | type Response struct { 5 | Message string `json:"msg"` 6 | } 7 | -------------------------------------------------------------------------------- /_examples/mvc/repository/datamodels/README.md: -------------------------------------------------------------------------------- 1 | # Data Model Layer -------------------------------------------------------------------------------- /_examples/mvc/repository/datamodels/movie.go: -------------------------------------------------------------------------------- 1 | // file: datamodels/movie.go 2 | 3 | package datamodels 4 | 5 | // Movie is our sample data structure. 6 | // Keep note that the tags for public-use (for our web app) 7 | // should be kept in other file like "web/viewmodels/movie.go" 8 | // which could wrap by embedding the datamodels.Movie or 9 | // declare new fields instead butwe will use this datamodel 10 | // as the only one Movie model in our application, 11 | // for the sake of simplicty. 12 | type Movie struct { 13 | ID int64 `json:"id"` 14 | Name string `json:"name"` 15 | Year int `json:"year"` 16 | Genre string `json:"genre"` 17 | Poster string `json:"poster"` 18 | } 19 | -------------------------------------------------------------------------------- /_examples/mvc/repository/datasource/README.md: -------------------------------------------------------------------------------- 1 | # Data Source / Data Store Layer -------------------------------------------------------------------------------- /_examples/mvc/repository/folder_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/mvc/repository/folder_structure.png -------------------------------------------------------------------------------- /_examples/mvc/repository/models/README.md: -------------------------------------------------------------------------------- 1 | # Domain Models 2 | 3 | There should be the domain/business-level models. 4 | 5 | Example: 6 | 7 | ```go 8 | import "github.com/kataras/iris/v12/_examples/mvc/repository/datamodels" 9 | 10 | type Movie struct { 11 | datamodels.Movie 12 | } 13 | 14 | func (m Movie) Validate() (Movie, error) { 15 | /* do some checks and return an error if that Movie is not valid */ 16 | } 17 | ``` 18 | 19 | However, we will use the "datamodels" as the only one models package because 20 | Movie structure we don't need any extra functionality or validation inside it. -------------------------------------------------------------------------------- /_examples/mvc/repository/repositories/README.md: -------------------------------------------------------------------------------- 1 | # Repositories 2 | 3 | The package which has direct access to the "datasource" and can manipulate data directly. -------------------------------------------------------------------------------- /_examples/mvc/repository/services/README.md: -------------------------------------------------------------------------------- 1 | # Service Layer 2 | 3 | The package which has access to call functions from the "repositories" and "models" ("datamodels" only in that simple example). It should contain the domain logic. -------------------------------------------------------------------------------- /_examples/mvc/repository/web/middleware/basicauth.go: -------------------------------------------------------------------------------- 1 | // file: web/middleware/basicauth.go 2 | 3 | package middleware 4 | 5 | import "github.com/kataras/iris/v12/middleware/basicauth" 6 | 7 | // BasicAuth middleware sample. 8 | var BasicAuth = basicauth.Default(map[string]string{ 9 | "admin": "password", 10 | }) 11 | -------------------------------------------------------------------------------- /_examples/mvc/repository/web/views/hello/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{.Title}} - My App 6 | 7 | 8 | 9 |

{{.MyMessage}}

10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/repository/web/views/hello/name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{.}}' Portfolio - My App 6 | 7 | 8 | 9 |

Hello {{.}}

10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/mvc/session-controller/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestMVCSession(t *testing.T) { 10 | e := httptest.New(t, newApp(), httptest.URL("http://example.com")) 11 | 12 | e1 := e.GET("/").Expect().Status(httptest.StatusOK) 13 | e1.Cookies().NotEmpty() 14 | e1.Body().Contains("1 visit") 15 | 16 | e.GET("/").Expect().Status(httptest.StatusOK). 17 | Body().Contains("2 visit") 18 | 19 | e.GET("/").Expect().Status(httptest.StatusOK). 20 | Body().Contains("3 visit") 21 | } 22 | -------------------------------------------------------------------------------- /_examples/mvc/vuejs-todo-mvc/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/mvc/vuejs-todo-mvc/screen.png -------------------------------------------------------------------------------- /_examples/mvc/vuejs-todo-mvc/src/todo/item.go: -------------------------------------------------------------------------------- 1 | package todo 2 | 3 | type Item struct { 4 | SessionID string `json:"-"` 5 | ID int64 `json:"id,omitempty"` 6 | Title string `json:"title"` 7 | Completed bool `json:"completed"` 8 | } 9 | -------------------------------------------------------------------------------- /_examples/mvc/vuejs-todo-mvc/src/web/public/css/index: -------------------------------------------------------------------------------- 1 | index.css is not here to reduce the disk space for the examples. 2 | https://unpkg.com/todomvc-app-css@2.0.4/index.css is used instead. -------------------------------------------------------------------------------- /_examples/mvc/vuejs-todo-mvc/src/web/public/js/lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/mvc/vuejs-todo-mvc/src/web/public/js/lib/.gitkeep -------------------------------------------------------------------------------- /_examples/mvc/websocket-auth/user.go: -------------------------------------------------------------------------------- 1 | //go:build go1.18 2 | // +build go1.18 3 | 4 | package main 5 | 6 | type AccessRole uint16 7 | 8 | func (r AccessRole) Is(v AccessRole) bool { 9 | return r&v != 0 10 | } 11 | 12 | func (r AccessRole) Allow(v AccessRole) bool { 13 | return r&v >= v 14 | } 15 | 16 | const ( 17 | InvalidAccessRole AccessRole = 1 << iota 18 | Read 19 | Write 20 | Delete 21 | 22 | Owner = Read | Write | Delete 23 | Member = Read | Write 24 | ) 25 | 26 | type User struct { 27 | ID string `json:"id"` 28 | Email string `json:"email"` 29 | Role AccessRole `json:"role"` 30 | } 31 | 32 | func (u User) GetID() string { 33 | return u.ID 34 | } 35 | -------------------------------------------------------------------------------- /_examples/mvc/websocket-auth/views/partials/footer.html: -------------------------------------------------------------------------------- 1 | Iris Web Framework © 2023 -------------------------------------------------------------------------------- /_examples/mvc/websocket-auth/views/signin.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_examples/pprof/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | 6 | "github.com/kataras/iris/v12/middleware/pprof" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | 12 | app.Get("/", func(ctx iris.Context) { 13 | ctx.HTML("

Please click here") 14 | }) 15 | 16 | p := pprof.New() 17 | app.Any("/debug/pprof", p) 18 | app.Any("/debug/pprof/{action:path}", p) 19 | // ___________ 20 | app.Listen(":8080") 21 | } 22 | -------------------------------------------------------------------------------- /_examples/project/README.md: -------------------------------------------------------------------------------- 1 | # Project Structure 2 | 3 | ```sh 4 | $ go run main.go --config=server.yml 5 | ``` -------------------------------------------------------------------------------- /_examples/project/api/users/api.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import ( 4 | "github.com/username/project/user" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | type API struct { 10 | Users user.Repository // exported field so api/router.go#api.RegisterDependency can bind it. 11 | } 12 | 13 | func (api *API) Configure(r iris.Party) { 14 | r.Post("/signup", api.signUp) 15 | r.Post("/signin", api.signIn) 16 | // Add middlewares such as user verification by bearer token here. 17 | 18 | // Authenticated routes... 19 | r.Get("/", api.getInfo) 20 | } 21 | 22 | func (api *API) getInfo(ctx iris.Context) { 23 | ctx.WriteString("...") 24 | } 25 | 26 | func (api *API) signUp(ctx iris.Context) {} 27 | func (api *API) signIn(ctx iris.Context) {} 28 | -------------------------------------------------------------------------------- /_examples/project/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/username/project/cmd" 8 | ) 9 | 10 | func main() { 11 | app := cmd.New() 12 | if err := app.Execute(); err != nil { 13 | fmt.Println(err) 14 | os.Exit(1) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /_examples/project/pkg/database/database.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | type DB struct { 4 | /* ... */ 5 | } 6 | 7 | func Open(connString string) *DB { 8 | return &DB{} 9 | } 10 | -------------------------------------------------------------------------------- /_examples/project/server.yml: -------------------------------------------------------------------------------- 1 | ServerName: My Project 2 | Env: development 3 | Host: 0.0.0.0 4 | Port: 80 5 | EnableCompression: true 6 | AllowOrigin: "*" 7 | Iris: 8 | # Defaults to info. 9 | LogLevel: info 10 | # Defaults to false. 11 | EnableOptimizations: true 12 | # Defaults to empty. 13 | RemoteAddrHeaders: 14 | - "X-Real-Ip" 15 | - "X-Forwarded-For" 16 | - "CF-Connecting-IP" 17 | - "True-Client-Ip" 18 | - "X-Appengine-Remote-Addr" 19 | -------------------------------------------------------------------------------- /_examples/project/user/repository.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import "github.com/username/project/pkg/database" 4 | 5 | type Repository interface { // Repo methods here... 6 | } 7 | 8 | type repo struct { // Hold database instance here: e.g. 9 | db *database.DB 10 | } 11 | 12 | func NewRepository(db *database.DB) Repository { 13 | return &repo{db: db} 14 | } 15 | -------------------------------------------------------------------------------- /_examples/project/user/user.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | type User struct { /* ... */ 4 | } 5 | -------------------------------------------------------------------------------- /_examples/recover/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | 6 | "github.com/kataras/iris/v12/middleware/recover" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.Use(recover.New()) 12 | 13 | i := 0 14 | // let's simulate a panic every next request 15 | app.Get("/", func(ctx iris.Context) { 16 | i++ 17 | if i%2 == 0 { 18 | panic("a panic here") 19 | } 20 | ctx.Writef("Hello, refresh one time more to get panic!") 21 | }) 22 | 23 | // http://localhost:8080, refresh it 5-6 times. 24 | app.Listen(":8080") 25 | } 26 | 27 | // Note: 28 | // app := iris.Default() instead of iris.New() makes use of the recovery middleware automatically. 29 | -------------------------------------------------------------------------------- /_examples/request-body/read-custom-per-type/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestReadCustomPerType(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | expectedResponse := `Received: main.config{Addr:"localhost:8080", ServerName:"Iris"}` 14 | 15 | e.POST("/").WithText("addr: localhost:8080\nserverName: Iris").Expect(). 16 | Status(httptest.StatusOK).Body().IsEqual(expectedResponse) 17 | } 18 | -------------------------------------------------------------------------------- /_examples/request-body/read-custom-via-unmarshaler/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestReadCustomViaUnmarshaler(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | expectedResponse := `Received: main.config{Addr:"localhost:8080", ServerName:"Iris"}` 14 | 15 | e.POST("/").WithText("addr: localhost:8080\nserverName: Iris").Expect(). 16 | Status(httptest.StatusOK).Body().IsEqual(expectedResponse) 17 | } 18 | -------------------------------------------------------------------------------- /_examples/request-body/read-form/checkboxes/templates/form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Select a color 7 | 8 | 9 |
10 |

Select one or more colors

11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | -------------------------------------------------------------------------------- /_examples/request-body/read-form/templates/form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | Username:
8 | Mail:
9 | Select one or more:
10 | 16 | 17 |
18 | 19 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /_examples/request-body/read-params/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestReadParams(t *testing.T) { 10 | app := newApp() 11 | 12 | e := httptest.New(t, app) 13 | 14 | expectedBody := `myParams: main.myParams{Name:"kataras", Age:27, Tail:[]string{"iris", "web", "framework"}}` 15 | e.GET("/kataras/27/iris/web/framework").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedBody) 16 | } 17 | -------------------------------------------------------------------------------- /_examples/request-body/read-url/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestReadURL(t *testing.T) { 10 | app := newApp() 11 | 12 | e := httptest.New(t, app) 13 | 14 | expectedBody := `myURL: main.myURL{Name:"kataras", Age:27, Tail:[]string{"iris", "web", "framework"}}` 15 | e.GET("/iris/web/framework").WithQuery("name", "kataras").WithQuery("age", 27).Expect().Status(httptest.StatusOK).Body().IsEqual(expectedBody) 16 | } 17 | -------------------------------------------------------------------------------- /_examples/request-body/read-xml/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestReadXML(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | expectedResponse := `Received: main.person{XMLName:xml.Name{Space:"", Local:"person"}, Name:"Winston Churchill", Age:90, Description:"Description of this person, the body of this inner element."}` 14 | send := `Description of this person, the body of this inner element.` 15 | 16 | e.POST("/").WithText(send).Expect(). 17 | Status(httptest.StatusOK).Body().IsEqual(expectedResponse) 18 | } 19 | -------------------------------------------------------------------------------- /_examples/request-body/read-yaml/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func newApp() *iris.Application { 8 | app := iris.New() 9 | app.Post("/", handler) 10 | 11 | return app 12 | } 13 | 14 | // simple yaml stuff, read more at https://yaml.org/start.html 15 | type product struct { 16 | Invoice int `yaml:"invoice"` 17 | Tax float32 `yaml:"tax"` 18 | Total float32 `yaml:"total"` 19 | Comments string `yaml:"comments"` 20 | } 21 | 22 | func handler(ctx iris.Context) { 23 | var p product 24 | if err := ctx.ReadYAML(&p); err != nil { 25 | ctx.StopWithError(iris.StatusBadRequest, err) 26 | return 27 | } 28 | 29 | ctx.Writef("Received: %#+v", p) 30 | } 31 | 32 | func main() { 33 | app := newApp() 34 | app.Listen(":8080") 35 | } 36 | -------------------------------------------------------------------------------- /_examples/request-body/read-yaml/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestReadYAML(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | expectedResponse := `Received: main.product{Invoice:34843, Tax:251.42, Total:4443.52, Comments:"Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."}` 14 | send := `invoice: 34843 15 | tax : 251.42 16 | total: 4443.52 17 | comments: > 18 | Late afternoon is best. 19 | Backup contact is Nancy 20 | Billsmer @ 338-4338.` 21 | 22 | e.POST("/").WithHeader("Content-Type", "application/x-yaml").WithBytes([]byte(send)).Expect(). 23 | Status(httptest.StatusOK).Body().IsEqual(expectedResponse) 24 | } 25 | -------------------------------------------------------------------------------- /_examples/response-writer/http2push/public/main.js: -------------------------------------------------------------------------------- 1 | window.alert("javascript loaded"); -------------------------------------------------------------------------------- /_examples/response-writer/protobuf/README.md: -------------------------------------------------------------------------------- 1 | # Protocol Buffers 2 | 3 | The `Context.Protobuf(proto.Message)` is the method which sends protos to the client. It accepts a [proto.Message](https://godoc.org/google.golang.org/protobuf/proto#Message) value. 4 | 5 | > Note: Iris is using the newest version of the Go protocol buffers implementation. Read more about it at [The Go Blog: A new Go API for Protocol Buffers](https://blog.golang.org/protobuf-apiv2). 6 | 7 | 8 | 1. Install the protoc-gen-go tool. 9 | 10 | ```sh 11 | $ go get -u google.golang.org/protobuf/cmd/protoc-gen-go@latest 12 | ``` 13 | 14 | 2. Generate proto 15 | 16 | ```sh 17 | $ protoc -I protos/ protos/hello.proto --go_out=. 18 | ``` 19 | -------------------------------------------------------------------------------- /_examples/response-writer/protobuf/protos/hello.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package protos; 4 | 5 | option go_package = "./protos"; 6 | 7 | message HelloRequest { 8 | string name = 1; 9 | } 10 | 11 | message HelloReply { 12 | string message = 1; 13 | } -------------------------------------------------------------------------------- /_examples/response-writer/sse-third-party-2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SSE Examples 5 | 6 | 7 | Messages 8 |
9 |
10 | 11 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /_examples/response-writer/sse/optional.sse.mini.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SSE (javascript side) 6 | 7 | 13 | 14 | 15 |

Open the browser's console(F12) and watch for incoming event messages

16 | 17 | -------------------------------------------------------------------------------- /_examples/routing/basic/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | node_modules 3 | bin -------------------------------------------------------------------------------- /_examples/routing/basic/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker build -t myapp . 2 | # docker run --rm -it -p 8080:8080 myapp:latest 3 | FROM golang:latest AS builder 4 | RUN apt-get update 5 | ENV GO111MODULE=on \ 6 | CGO_ENABLED=0 \ 7 | GOOS=linux \ 8 | GOARCH=amd64 9 | WORKDIR /go/src/app 10 | COPY go.mod . 11 | RUN go mod download 12 | COPY . . 13 | RUN go install 14 | 15 | FROM scratch 16 | COPY --from=builder /go/bin/app . 17 | ENTRYPOINT ["./app"] -------------------------------------------------------------------------------- /_examples/routing/basic/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # docker-compose up [--build] 2 | version: '3' 3 | 4 | services: 5 | app: 6 | build: . 7 | ports: 8 | - 8080:8080 -------------------------------------------------------------------------------- /_examples/routing/conditional-chain/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestNewConditionalHandler(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | e.GET("/api/v1/users").Expect().Status(httptest.StatusOK). 14 | Body().IsEqual("requested: /api/v1/users") 15 | e.GET("/api/v1/users").WithQuery("admin", "true").Expect().Status(httptest.StatusOK). 16 | Body().IsEqual("Admin\n

Hello Admin


requested: /api/v1/users") 17 | } 18 | -------------------------------------------------------------------------------- /_examples/routing/custom-wrapper/public/app.js: -------------------------------------------------------------------------------- 1 | window.alert("app.js loaded from \"/"); -------------------------------------------------------------------------------- /_examples/routing/custom-wrapper/public/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/routing/custom-wrapper/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Index Page 5 | 6 | 7 | 8 |

Hello from index.html

9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /_examples/routing/dynamic-path/same-pattern-different-func/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/kataras/iris/v12" 4 | 5 | func main() { 6 | app := newApp() 7 | app.Logger().SetLevel("debug") 8 | app.Listen(":8080") 9 | } 10 | 11 | func newApp() *iris.Application { 12 | app := iris.New() 13 | 14 | app.HandleMany(iris.MethodGet, "/ /api/{page:string suffix(.html)}", handler1) 15 | app.Get("/api/{name:string suffix(.zip)}", handler2) 16 | 17 | return app 18 | } 19 | 20 | func handler1(ctx iris.Context) { 21 | reply(ctx) 22 | } 23 | 24 | func handler2(ctx iris.Context) { 25 | reply(ctx) 26 | } 27 | 28 | func reply(ctx iris.Context) { 29 | ctx.JSON(iris.Map{ 30 | "handler": ctx.HandlerName(), 31 | "params": ctx.Params().Store, 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /_examples/routing/dynamic-path/same-pattern-different-func/use-global/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/kataras/iris/v12/httptest" 8 | ) 9 | 10 | func TestSamePatternDifferentFuncUseGlobal(t *testing.T) { 11 | app := newApp() 12 | e := httptest.New(t, app) 13 | 14 | expectedResultFmt := "Called first middleware\nCalled second middleware\n%s\nCalled done: %s" 15 | tests := map[string]string{ 16 | "/one-num": "first route", 17 | "/two-num": "second route", 18 | "/three-num": "third route", 19 | } 20 | 21 | for path, mainBody := range tests { 22 | result := fmt.Sprintf(expectedResultFmt, mainBody, path[1:]) 23 | e.GET(path).Expect().Status(httptest.StatusOK).Body().IsEqual(result) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /_examples/routing/http-errors/reset-body/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestResetCompressionAndFireError(t *testing.T) { // #1569 10 | app := newApp() 11 | 12 | e := httptest.New(t, app) 13 | e.GET("/").Expect().Status(httptest.StatusBadRequest).Body().IsEqual("custom error") 14 | } 15 | -------------------------------------------------------------------------------- /_examples/routing/intelligence/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/kataras/iris/v12" 4 | 5 | func main() { 6 | app := iris.New() 7 | app.Get("/home", handler) 8 | app.Get("/contact", handler) 9 | app.Get("/contract", handler) 10 | 11 | // http://localhost:8080/home 12 | // http://localhost:8080/hom 13 | // 14 | // http://localhost:8080/contact 15 | // http://localhost:8080/cont 16 | // 17 | // http://localhost:8080/contract 18 | // http://localhost:8080/contr 19 | app.Listen(":8080", iris.WithPathIntelligence) 20 | } 21 | 22 | func handler(ctx iris.Context) { 23 | ctx.Writef("Path: %s", ctx.Path()) 24 | } 25 | -------------------------------------------------------------------------------- /_examples/routing/overview-2/views/user/create_verification.html: -------------------------------------------------------------------------------- 1 | 2 | Create verification 3 | 4 |

Create Verification

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
UsernameFirstnameLastnameCityAge
{{ .Username }}{{ .Firstname }}{{ .Lastname }}{{ .City }}{{ .Age }}
21 | 22 | 23 | -------------------------------------------------------------------------------- /_examples/routing/overview-2/views/user/profile.html: -------------------------------------------------------------------------------- 1 | 2 | Profile page 3 | 4 |

Profile

5 | {{ .Username }} 6 | 7 | 8 | -------------------------------------------------------------------------------- /_examples/routing/overview/public/assets/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: black; 3 | } 4 | -------------------------------------------------------------------------------- /_examples/routing/overview/public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/routing/overview/public/images/favicon.ico -------------------------------------------------------------------------------- /_examples/routing/remove-handler/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/kataras/iris/v12" 4 | 5 | func main() { 6 | app := newApp() 7 | app.Listen(":8080") 8 | } 9 | 10 | func newApp() *iris.Application { 11 | app := iris.New() 12 | 13 | api := app.Party("/api") 14 | api.Use(myMiddleware) 15 | users := api.Party("/users") 16 | users.Get("/", usersIndex).RemoveHandler(myMiddleware) 17 | // OR for all routes under a Party (or Application): 18 | // users.RemoveHandler(...) 19 | 20 | return app 21 | } 22 | 23 | func myMiddleware(ctx iris.Context) { 24 | ctx.WriteString("Middleware\n") 25 | } 26 | 27 | func usersIndex(ctx iris.Context) { 28 | ctx.WriteString("OK") 29 | } 30 | -------------------------------------------------------------------------------- /_examples/routing/remove-handler/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestSimpleRouteRemoveHandler(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | e.GET("/api/users").Expect().Status(httptest.StatusOK).Body().IsEqual("OK") 14 | } 15 | -------------------------------------------------------------------------------- /_examples/routing/remove-route/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | func main() { 8 | app := iris.New() 9 | app.Get("/", index) 10 | app.Get("/about", about).SetName("about_page") 11 | app.RemoveRoute("about_page") 12 | 13 | // http://localhost:8080 14 | // http://localhost:8080/about (Not Found) 15 | app.Listen(":8080") 16 | } 17 | 18 | func index(ctx iris.Context) { 19 | ctx.WriteString("Hello, Gophers!") 20 | } 21 | 22 | func about(ctx iris.Context) { 23 | ctx.HTML("

About Page

") 24 | } 25 | -------------------------------------------------------------------------------- /_examples/routing/rewrite/hosts: -------------------------------------------------------------------------------- 1 | 127.0.0.1 mydomain.com 2 | 127.0.0.1 www.mydomain.com 3 | 127.0.0.1 test.mydomain.com 4 | 127.0.0.1 newtest.mydomain.com 5 | -------------------------------------------------------------------------------- /_examples/routing/route-register-rule/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/core/router" 7 | "github.com/kataras/iris/v12/httptest" 8 | ) 9 | 10 | func TestRouteRegisterRuleExample(t *testing.T) { 11 | app := newApp() 12 | e := httptest.New(t, app) 13 | 14 | for _, method := range router.AllMethods { 15 | tt := e.Request(method, "/").Expect().Status(httptest.StatusOK).Body() 16 | if method == "GET" { 17 | tt.Equal("From GET: iris/_examples/routing/route-register-rule.getHandler") 18 | } else { 19 | tt.Equal("From " + method + ": iris/_examples/routing/route-register-rule.anyHandler") 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/http-errors-view/views/error.html: -------------------------------------------------------------------------------- 1 |
2 |

Oups, you've got an error!

3 | {{ if .ErrorCode }} 4 | {{ $tmplName := print "partials/" .ErrorCode ".html"}} 5 | {{ render $tmplName . }} 6 | {{ else }} 7 | {{ render "partials/500.html" . }} 8 | {{ end }} 9 |
10 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/http-errors-view/views/index.html: -------------------------------------------------------------------------------- 1 |
2 | Index Page 3 |
4 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/http-errors-view/views/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Website Layout 4 | 5 | 6 | 7 |

This is the global layout

8 |
9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/http-errors-view/views/layouts/test.layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test Subdomain 4 | 5 | 6 | 7 | 8 | {{ yield . }} 9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/http-errors-view/views/partials/404.html: -------------------------------------------------------------------------------- 1 |
2 |

Not Found

3 |
4 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/http-errors-view/views/partials/500.html: -------------------------------------------------------------------------------- 1 |
2 |

Internal Server Error

3 |
4 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/multi/public/assets/images/test.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/routing/subdomains/multi/public/assets/images/test.ico -------------------------------------------------------------------------------- /_examples/routing/subdomains/multi/public/upload_resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/routing/subdomains/multi/public/upload_resources/favicon.ico -------------------------------------------------------------------------------- /_examples/routing/subdomains/redirect/hosts: -------------------------------------------------------------------------------- 1 | 127.0.0.1 mydomain.com 2 | 127.0.0.1 www.mydomain.com 3 | 127.0.0.1 otherdomain.com 4 | 5 | # Windows: Drive:/Windows/system32/drivers/etc/hosts, on Linux: /etc/hosts -------------------------------------------------------------------------------- /_examples/routing/subdomains/redirect/multi-instances/other/server.go: -------------------------------------------------------------------------------- 1 | package other 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func init() { 10 | app := iris.New() 11 | app.SetName("other app") 12 | 13 | app.OnAnyErrorCode(handleErrors) 14 | app.Get("/", index) 15 | } 16 | 17 | func index(ctx iris.Context) { 18 | ctx.HTML("Other Index (App Name: %s | Host: %s)", 19 | ctx.Application().String(), ctx.Host()) 20 | } 21 | 22 | func handleErrors(ctx iris.Context) { 23 | errCode := ctx.GetStatusCode() 24 | ctx.JSON(iris.Map{ 25 | "Server": ctx.Application().String(), 26 | "Code": errCode, 27 | "Message": iris.StatusText(errCode), 28 | "Timestamp": time.Now().Unix(), 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /_examples/routing/subdomains/redirect/multi-instances/root/server.go: -------------------------------------------------------------------------------- 1 | package root 2 | 3 | import "github.com/kataras/iris/v12" 4 | 5 | func init() { 6 | app := iris.New() 7 | app.SetName("root app") 8 | 9 | app.Get("/", index) 10 | } 11 | 12 | func index(ctx iris.Context) { 13 | ctx.HTML("Main Root Index (App Name: %s | Host: %s)", 14 | ctx.Application().String(), ctx.Host()) 15 | } 16 | -------------------------------------------------------------------------------- /_examples/routing/versioning/v1/index.html: -------------------------------------------------------------------------------- 1 |

This is the directory for version 1 templates

-------------------------------------------------------------------------------- /_examples/routing/versioning/v2/index.html: -------------------------------------------------------------------------------- 1 |

This is the directory for version 2 templates

-------------------------------------------------------------------------------- /_examples/routing/versioning/v3/index.html: -------------------------------------------------------------------------------- 1 |

This is the directory for version 3 templates

-------------------------------------------------------------------------------- /_examples/routing/writing-a-middleware/share-funcs/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestShareFuncs(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | e.GET("/").Expect().Status(httptest.StatusOK).Body().IsEqual("Hello, Gophers!") 14 | e.GET("/2").Expect().Status(httptest.StatusOK).Body().IsEqual("Hello, Gophers [2]!") 15 | e.GET("/3").Expect().Status(httptest.StatusOK).Body().IsEqual("OK, job was executed.\nSee the command prompt.") 16 | } 17 | -------------------------------------------------------------------------------- /_examples/routing/writing-a-middleware/share-services/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/kataras/iris/v12/httptest" 7 | ) 8 | 9 | func TestShareServices(t *testing.T) { 10 | app := newApp() 11 | e := httptest.New(t, app) 12 | 13 | e.GET("/").Expect().Status(httptest.StatusOK).Body().IsEqual("Hello, Gophers!") 14 | } 15 | -------------------------------------------------------------------------------- /_examples/sessions/database/redis/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:latest AS builder 2 | RUN apt-get update 3 | WORKDIR /go/src/app 4 | ENV GO111MODULE=on \ 5 | CGO_ENABLED=0 \ 6 | GOOS=linux \ 7 | GOARCH=amd64 8 | # Caching go modules and build the binary. 9 | COPY go.mod . 10 | RUN go mod download 11 | COPY . . 12 | RUN go install 13 | 14 | FROM scratch 15 | COPY --from=builder /go/bin/app . 16 | ENTRYPOINT ["./app"] -------------------------------------------------------------------------------- /_examples/sessions/database/redis/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # docker-compose up [--build] 2 | version: '3' 3 | 4 | services: 5 | redis-server: 6 | image: redis 7 | app1: 8 | build: . 9 | depends_on: 10 | - redis-server 11 | ports: 12 | - 8080:8080 13 | environment: 14 | - PORT=8080 15 | - REDIS_ADDR=redis-server:6379 16 | app2: 17 | build: . 18 | depends_on: 19 | - redis-server 20 | ports: 21 | - 9090:9090 22 | environment: 23 | - PORT=9090 24 | - REDIS_ADDR=redis-server:6379 -------------------------------------------------------------------------------- /_examples/sessions/viewdata/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Sessions View Data 7 | 8 | 9 | Hello {{.session.Get "username"}} 10 | 11 | -------------------------------------------------------------------------------- /_examples/url-shortener/README.md: -------------------------------------------------------------------------------- 1 | ## A URL Shortener Service using Go, Iris and Bolt 2 | 3 | Hackernoon Article: https://medium.com/hackernoon/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7 -------------------------------------------------------------------------------- /_examples/url-shortener/resources/css/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background-color:silver; 3 | } -------------------------------------------------------------------------------- /_examples/url-shortener/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Golang URL Shortener 6 | 7 | 8 | 9 | 10 |

Golang URL Shortener

11 |

{{ .FORM_RESULT}}

12 |
13 | 14 | 15 |
16 | {{ if IsPositive .URL_COUNT }} 17 |

{{ .URL_COUNT }} URLs shortened

18 | {{ end }} 19 | 20 |
21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /_examples/view/context-view-data/templates/index.html: -------------------------------------------------------------------------------- 1 |

2 | Title: {{.Title}} 3 |

4 |

{{.BodyMessage}}

5 | 6 |
7 | 8 | Current time: {{.CurrentTime}} -------------------------------------------------------------------------------- /_examples/view/context-view-data/templates/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | My WebsiteLayout 4 | 5 | 6 | 7 | 8 | {{ yield . }} 9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/admin/index.html: -------------------------------------------------------------------------------- 1 | {{ define "content" }} 2 |

Hello, Admin!

3 | {{ end }} -------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/admin/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ .Title }} 7 | 8 | 9 | {{ template "content" .}} 10 | 11 | 12 |

Copyright © 2022 Admin

13 | 14 | -------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/on-fly/index.html: -------------------------------------------------------------------------------- 1 |

On-fly

2 |

{{.Message}}

-------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/public/500.html: -------------------------------------------------------------------------------- 1 | 6 | {{ define "content" }} 7 |

Internal Server Error

8 | {{ end }} 9 | 10 | {{ define "message" }} 11 |

{{.Message}}

12 | {{ end }} -------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/public/index.html: -------------------------------------------------------------------------------- 1 |

Index Body

-------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/public/layouts/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{.Code}} 7 | 8 | 9 | {{ template "content" .}} 10 | 11 | {{block "message" .}}{{end}} 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/public/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ if .Title }}{{ .Title }}{{ else }}Default Main Title{{ end }} 7 | 8 | 9 | {{ template "content" . }} 10 | 11 |
{{ partial "partials/footer" . }}
12 | 13 | -------------------------------------------------------------------------------- /_examples/view/context-view-engine/views/public/partials/footer.html: -------------------------------------------------------------------------------- 1 |

Footer Partial

-------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app-bindata/templates/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Layout 4 | 5 | 6 | 7 |

This is the global layout

8 |
9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app-bindata/templates/layouts/mylayout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | my Layout 4 | 5 | 6 | 7 |

This is the layout for the /my/ and /my/other routes only

8 |
9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app-bindata/templates/page1.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Page 1 {{ greet "iris developer"}}

4 | 5 | {{ render "partials/page1_partial1.html" . }} 6 | 7 |
8 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app-bindata/templates/partials/page1_partial1.html: -------------------------------------------------------------------------------- 1 |
2 |

Page 1's Partial 1

3 |
4 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app/embedded/templates/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Layout 4 | 5 | 6 | 7 |

This is the global layout

8 |
9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app/embedded/templates/layouts/mylayout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | my Layout 4 | 5 | 6 | 7 |

This is the layout for the /my/ and /my/other routes only

8 |
9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app/embedded/templates/page1.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Page 1 {{ greet "iris developer"}}

4 | 5 | {{ render "partials/page1_partial1.html" . }} 6 | 7 |
8 | -------------------------------------------------------------------------------- /_examples/view/embedding-templates-into-app/embedded/templates/partials/page1_partial1.html: -------------------------------------------------------------------------------- 1 |
2 |

Page 1's Partial 1

3 |
4 | -------------------------------------------------------------------------------- /_examples/view/fallback/view/fallback.html: -------------------------------------------------------------------------------- 1 |

Fallback view

-------------------------------------------------------------------------------- /_examples/view/herotemplate/README.md: -------------------------------------------------------------------------------- 1 | # Hero Template Example 2 | 3 | This folder contains the iris version of the original hero's example: https://github.com/shiyanhui/hero/tree/master/examples/app. 4 | 5 | Iris is 100% compatible with `net/http` so you don't have to change anything else 6 | except the handler input from the original example. 7 | 8 | The only inline handler's changes were: 9 | 10 | From: 11 | 12 | ```go 13 | if _, err := w.Write(buffer.Bytes()); err != nil { 14 | // and 15 | template.UserListToWriter(userList, w) 16 | ``` 17 | To: 18 | ```go 19 | if _, err := ctx.Write(buffer.Bytes()); err != nil { 20 | // and 21 | template.UserListToWriter(userList, ctx) 22 | ``` 23 | 24 | So easy. 25 | 26 | Read more at: https://github.com/shiyanhui/hero -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%@ body { %> 9 | <% } %> 10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/index.html.go: -------------------------------------------------------------------------------- 1 | // Code generated by hero. 2 | // DO NOT EDIT! 3 | package template 4 | -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/user.html: -------------------------------------------------------------------------------- 1 |
  • 2 | <%= user %> 3 |
  • 4 | -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/user.html.go: -------------------------------------------------------------------------------- 1 | // Code generated by hero. 2 | // DO NOT EDIT! 3 | package template 4 | -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/userlist.html: -------------------------------------------------------------------------------- 1 | <%: func UserList(userList []string, buffer *bytes.Buffer) %> 2 | 3 | <%~ "index.html" %> 4 | 5 | <%@ body { %> 6 | <% for _, user := range userList { %> 7 |
      8 | <%+ "user.html" %> 9 |
    10 | <% } %> 11 | <% } %> 12 | -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/userlist.html.go: -------------------------------------------------------------------------------- 1 | // Code generated by hero. 2 | // DO NOT EDIT! 3 | package template 4 | 5 | import ( 6 | "bytes" 7 | 8 | "github.com/shiyanhui/hero" 9 | ) 10 | 11 | func UserList(userList []string, buffer *bytes.Buffer) { 12 | buffer.WriteString(` 13 | 14 | 15 | 16 | 17 | 18 | 19 | `) 20 | for _, user := range userList { 21 | buffer.WriteString(` 22 |
      23 | `) 24 | buffer.WriteString(`
    • 25 | `) 26 | hero.EscapeHTML(user, buffer) 27 | buffer.WriteString(` 28 |
    • 29 | `) 30 | 31 | buffer.WriteString(` 32 |
    33 | `) 34 | } 35 | 36 | buffer.WriteString(` 37 | 38 | 39 | `) 40 | } 41 | -------------------------------------------------------------------------------- /_examples/view/herotemplate/template/userlistwriter.html: -------------------------------------------------------------------------------- 1 | <%: func UserListToWriter(userList []string, w io.Writer) (int, error)%> 2 | 3 | <%~ "index.html" %> 4 | 5 | <%@ body { %> 6 | <% for _, user := range userList { %> 7 |
      8 | <%+ "user.html" %> 9 |
    10 | <% } %> 11 | <% } %> 12 | -------------------------------------------------------------------------------- /_examples/view/layout/ace/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | // By default Ace minifies the template before render, 12 | // using the SetIndent method, we make it to match 13 | // the rest of the template results. 14 | app.RegisterView(iris.Ace("./views", ".ace").SetIndent(" ")) 15 | 16 | app.Get("/", index) 17 | 18 | app.Listen(":8080") 19 | } 20 | 21 | func index(ctx iris.Context) { 22 | data := iris.Map{ 23 | "Title": "Page Title", 24 | "FooterText": "Footer contents", 25 | "Message": "Main contents", 26 | } 27 | 28 | ctx.ViewLayout("layouts/main") 29 | if err := ctx.View("index", data); err != nil { 30 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_examples/view/layout/ace/views/index.ace: -------------------------------------------------------------------------------- 1 | h1 Index Body 2 | h3 Message: {{.Message}} -------------------------------------------------------------------------------- /_examples/view/layout/ace/views/layouts/main.ace: -------------------------------------------------------------------------------- 1 | = doctype html 2 | html 3 | head 4 | title {{.Title}} 5 | body 6 | {{ yield . }} 7 | footer 8 | = include partials/footer.ace . -------------------------------------------------------------------------------- /_examples/view/layout/ace/views/partials/footer.ace: -------------------------------------------------------------------------------- 1 | h3 Footer Partial 2 | h4 {{.FooterText}} -------------------------------------------------------------------------------- /_examples/view/layout/blocks/views/index.html: -------------------------------------------------------------------------------- 1 |

    Index Body

    2 |

    Message: {{.Message}}

    -------------------------------------------------------------------------------- /_examples/view/layout/blocks/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{.Title}} 4 | 5 | 6 | {{ template "content" . }} 7 |
    8 | {{ partial "partials/footer" . }} 9 |
    10 | 11 | -------------------------------------------------------------------------------- /_examples/view/layout/blocks/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

    Footer Partial

    2 |

    {{.FooterText}}

    -------------------------------------------------------------------------------- /_examples/view/layout/django/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.RegisterView(iris.Django("./views", ".html")) 12 | 13 | app.Get("/", index) 14 | 15 | app.Listen(":8080") 16 | } 17 | 18 | func index(ctx iris.Context) { 19 | data := iris.Map{ 20 | "Title": "Page Title", 21 | "FooterText": "Footer contents", 22 | "Message": "Main contents", 23 | } 24 | 25 | // On Django this is ignored: ctx.ViewLayout("layouts/main") 26 | // Layouts are only rendered from inside the index page itself 27 | // using the "extends" keyword. 28 | if err := ctx.View("index", data); err != nil { 29 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 30 | return 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_examples/view/layout/django/views/index.html: -------------------------------------------------------------------------------- 1 | {% extends "layouts/main.html" %} 2 | 3 | {% block content %} 4 |

    Index Body

    5 |

    Message: {{Message}}

    6 | {% endblock %} -------------------------------------------------------------------------------- /_examples/view/layout/django/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{Title}} 4 | 5 | 6 | {% block content %} {% endblock %} 7 | 8 |
    {% include "../partials/footer.html" %}
    9 | 10 | -------------------------------------------------------------------------------- /_examples/view/layout/django/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

    Footer Partial

    2 |

    {{FooterText}}

    -------------------------------------------------------------------------------- /_examples/view/layout/handlebars/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | 12 | app.RegisterView(iris.Handlebars("./views", ".html")) 13 | 14 | app.Get("/", index) 15 | 16 | app.Listen(":8080") 17 | } 18 | 19 | func index(ctx iris.Context) { 20 | data := iris.Map{ 21 | "Title": "Page Title", 22 | "FooterText": "Footer contents", 23 | "Message": "Main contents", 24 | } 25 | 26 | ctx.ViewLayout("layouts/main") 27 | if err := ctx.View("index", data); err != nil { 28 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 29 | return 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /_examples/view/layout/handlebars/views/index.html: -------------------------------------------------------------------------------- 1 |

    Index Body

    2 |

    Message: {{Message}}

    -------------------------------------------------------------------------------- /_examples/view/layout/handlebars/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{Title}} 4 | 5 | 6 | {{ yield . }} 7 | 8 |
    {{ render "partials/footer.html" .}}
    9 | 10 | -------------------------------------------------------------------------------- /_examples/view/layout/handlebars/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

    Footer Partial

    2 |

    {{FooterText}}

    -------------------------------------------------------------------------------- /_examples/view/layout/html/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | 12 | app.RegisterView(iris.HTML("./views", ".html")) 13 | 14 | app.Get("/", index) 15 | 16 | app.Listen(":8080") 17 | } 18 | 19 | func index(ctx iris.Context) { 20 | data := iris.Map{ 21 | "Title": "Page Title", 22 | "FooterText": "Footer contents", 23 | "Message": "Main contents", 24 | } 25 | 26 | ctx.ViewLayout("layouts/main") 27 | if err := ctx.View("index", data); err != nil { 28 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 29 | return 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /_examples/view/layout/html/views/index.html: -------------------------------------------------------------------------------- 1 |

    Index Body

    2 |

    Message: {{.Message}}

    -------------------------------------------------------------------------------- /_examples/view/layout/html/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{.Title}} 4 | 5 | 6 | {{ yield . }} 7 |
    8 | {{ render "partials/footer.html" . }} 9 |
    10 | 11 | -------------------------------------------------------------------------------- /_examples/view/layout/html/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

    Footer Partial

    2 |

    {{.FooterText}}

    -------------------------------------------------------------------------------- /_examples/view/layout/jet/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | 12 | app.RegisterView(iris.Jet("./views", ".jet")) 13 | 14 | app.Get("/", index) 15 | 16 | app.Listen(":8080") 17 | } 18 | 19 | func index(ctx iris.Context) { 20 | data := iris.Map{ 21 | "Title": "Page Title", 22 | "FooterText": "Footer contents", 23 | "Message": "Main contents", 24 | } 25 | 26 | // On Jet this is ignored: ctx.ViewLayout("layouts/main") 27 | // Layouts are only rendered from inside the index page itself 28 | // using the "extends" keyword. 29 | if err := ctx.View("index", data); err != nil { 30 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_examples/view/layout/jet/views/index.jet: -------------------------------------------------------------------------------- 1 | {{ extends "../layouts/main.jet" }} 2 | {{ block documentBody() }} 3 |

    Index Body

    4 |

    Message: {{.Message}}

    5 | {{ end }} -------------------------------------------------------------------------------- /_examples/view/layout/jet/views/layouts/main.jet: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{.Title}} 4 | 5 | 6 | {{ yield . documentBody() }} 7 |
    {{ include "../partials/footer.jet" . }}
    8 | 9 | -------------------------------------------------------------------------------- /_examples/view/layout/jet/views/partials/footer.jet: -------------------------------------------------------------------------------- 1 |

    Footer Partial

    2 |

    {{.FooterText}}

    -------------------------------------------------------------------------------- /_examples/view/layout/pug/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | app := iris.New() 11 | app.RegisterView(iris.Pug("./views", ".pug")) 12 | 13 | app.Get("/", index) 14 | 15 | app.Listen(":8080") 16 | } 17 | 18 | func index(ctx iris.Context) { 19 | data := iris.Map{ 20 | "Title": "Page Title", 21 | "FooterText": "Footer contents", 22 | "Message": "Main contents", 23 | } 24 | 25 | // On Pug this is ignored: ctx.ViewLayout("layouts/main") 26 | // Layouts are only rendered from inside the index page itself 27 | // using the "extends" keyword. 28 | if err := ctx.View("index", data); err != nil { 29 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 30 | return 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_examples/view/layout/pug/views/index.pug: -------------------------------------------------------------------------------- 1 | extends layouts/main.pug 2 | 3 | block content 4 | h1 Index Body 5 | h3 Message: {{.Message}} -------------------------------------------------------------------------------- /_examples/view/layout/pug/views/layouts/main.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title {{.Title}} 5 | body 6 | block content 7 | footer 8 | include ../partials/footer.pug -------------------------------------------------------------------------------- /_examples/view/layout/pug/views/partials/footer.pug: -------------------------------------------------------------------------------- 1 | h3 Footer Partial 2 | h4 {{.FooterText}} -------------------------------------------------------------------------------- /_examples/view/overview/templates/functions.html: -------------------------------------------------------------------------------- 1 |

    Function: {{ Now }}

    2 |

    Field: {{ .Ctx.Request.URL.Path }}

    3 |

    Field Struct's Function (Method): {{ .Ctx.FullRequestURI }}

    4 | -------------------------------------------------------------------------------- /_examples/view/overview/templates/hi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hi iris 5 | 6 | 7 | 8 |

    Hi {{.Name}}

    9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/view/parse-template/django/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | e := iris.Django(nil, ".html") // You can still use a file system though. 11 | e.AddFunc("greet", func(name string) string { 12 | return "Hello, " + name + "!" 13 | }) 14 | err := e.ParseTemplate("program.html", []byte(`

    {{greet(Name)}}

    `)) 15 | if err != nil { 16 | panic(err) 17 | } 18 | e.Reload(true) 19 | 20 | app := iris.New() 21 | app.RegisterView(e) 22 | app.Get("/", index) 23 | 24 | app.Listen(":8080") 25 | } 26 | 27 | func index(ctx iris.Context) { 28 | if err := ctx.View("program.html", iris.Map{ 29 | "Name": "Gerasimos", 30 | }); err != nil { 31 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 32 | return 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /_examples/view/parse-template/handlebars/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func main() { 10 | e := iris.Handlebars(nil, ".html") // You can still use a file system though. 11 | e.ParseTemplate("program.html", `

    {{greet Name}}

    `, iris.Map{ 12 | "greet": func(name string) string { 13 | return "Hello, " + name + "!" 14 | }, 15 | }) 16 | e.Reload(true) 17 | 18 | app := iris.New() 19 | app.RegisterView(e) 20 | app.Get("/", index) 21 | 22 | app.Listen(":8080") 23 | } 24 | 25 | func index(ctx iris.Context) { 26 | if err := ctx.View("program.html", iris.Map{ 27 | "Name": "Gerasimos", 28 | }); err != nil { 29 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 30 | return 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_examples/view/parse-template/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | My Layout 4 | 5 | 6 | 7 |

    [layout] Body content is below...

    8 | 9 | {{ yield . }} 10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/view/quicktemplate/controllers/execute_template.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/_examples/view/quicktemplate/templates" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | // ExecuteTemplate renders a "tmpl" partial template to the `Context.ResponseWriter`. 10 | func ExecuteTemplate(ctx iris.Context, tmpl templates.Partial) { 11 | ctx.CompressWriter(true) 12 | ctx.ContentType("text/html") 13 | templates.WriteTemplate(ctx, tmpl) 14 | } 15 | -------------------------------------------------------------------------------- /_examples/view/quicktemplate/controllers/index.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/_examples/view/quicktemplate/templates" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | // Index renders our ../templates/index.qtpl file using the compiled ../templates/index.qtpl.go file. 10 | func Index(ctx iris.Context) { 11 | tmpl := &templates.Index{} 12 | 13 | // render the template 14 | ExecuteTemplate(ctx, tmpl) 15 | } 16 | -------------------------------------------------------------------------------- /_examples/view/quicktemplate/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/_examples/view/quicktemplate/controllers" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | func newApp() *iris.Application { 10 | app := iris.New() 11 | app.Get("/", controllers.Index) 12 | app.Get("/{name}", controllers.Hello) 13 | 14 | return app 15 | } 16 | 17 | func main() { 18 | app := newApp() 19 | // http://localhost:8080 20 | // http://localhost:8080/yourname 21 | app.Listen(":8080") 22 | } 23 | -------------------------------------------------------------------------------- /_examples/view/quicktemplate/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/view/quicktemplate/models/.gitkeep -------------------------------------------------------------------------------- /_examples/view/quicktemplate/templates/hello.qtpl: -------------------------------------------------------------------------------- 1 | Hello template, implements the Partial's methods. 2 | 3 | {% code 4 | type Hello struct { 5 | Vars map[string]interface{} 6 | } 7 | %} 8 | 9 | {% func (h *Hello) Body() %} 10 |

    {%v h.Vars["message"] %}

    11 |
    12 | Hello {%v h.Vars["name"] %}! 13 |
    14 | {% endfunc %} 15 | -------------------------------------------------------------------------------- /_examples/view/quicktemplate/templates/index.qtpl: -------------------------------------------------------------------------------- 1 | Index template, implements the Partial's methods. 2 | 3 | {% code 4 | type Index struct {} 5 | %} 6 | 7 | {% func (i *Index) Body() %} 8 |

    Index Page

    9 |
    10 | This is our index page's body. 11 |
    12 | {% endfunc %} 13 | -------------------------------------------------------------------------------- /_examples/view/templ/hello.templ: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | templ hello(name string) { 4 |
    Hello, { name }
    5 | } -------------------------------------------------------------------------------- /_examples/view/templ/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/kataras/iris/v12" 5 | ) 6 | 7 | // $ go install github.com/a-h/templ/cmd/templ@latest 8 | // $ templ generate 9 | // $ go run . 10 | func main() { 11 | component := hello("Makis") 12 | 13 | app := iris.New() 14 | app.Get("/", iris.Component(component)) 15 | 16 | app.Listen(":8080") 17 | } 18 | -------------------------------------------------------------------------------- /_examples/view/template_ace_0/views/index.ace: -------------------------------------------------------------------------------- 1 | = include partials/header.ace . 2 | 3 | h2 {{.Title}} 4 | 5 | h3 Body 6 | 7 | = include partials/footer.ace . -------------------------------------------------------------------------------- /_examples/view/template_ace_0/views/layouts/main.ace: -------------------------------------------------------------------------------- 1 | = doctype html 2 | html 3 | head 4 | title Main Page 5 | body 6 | h1 Layout 7 | {{ yield . }} -------------------------------------------------------------------------------- /_examples/view/template_ace_0/views/partials/footer.ace: -------------------------------------------------------------------------------- 1 | h1 Partial Footer -------------------------------------------------------------------------------- /_examples/view/template_ace_0/views/partials/header.ace: -------------------------------------------------------------------------------- 1 | h1 Partial Header -------------------------------------------------------------------------------- /_examples/view/template_blocks_0/views/500.html: -------------------------------------------------------------------------------- 1 | {{ define "content" }} 2 |

    Internal Server Error

    3 | {{ end }} 4 | 5 | {{ define "message" }} 6 |

    {{.Message}}

    7 | {{ end }} -------------------------------------------------------------------------------- /_examples/view/template_blocks_0/views/index.html: -------------------------------------------------------------------------------- 1 |

    Index Body

    -------------------------------------------------------------------------------- /_examples/view/template_blocks_0/views/layouts/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{.Code}} 7 | 8 | 9 | {{ template "content" . }} 10 | 11 | {{ block "message" . }}Default Error Message{{ end }} 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/template_blocks_0/views/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ if .Title }}{{ .Title }}{{ else }}Default Main Title{{ end }} 7 | 8 | 9 | {{ template "content" . }} 10 | 11 |
    {{ partial "partials/footer" . }}
    12 | 13 | -------------------------------------------------------------------------------- /_examples/view/template_blocks_0/views/partials/footer.html: -------------------------------------------------------------------------------- 1 |

    Footer Partial

    -------------------------------------------------------------------------------- /_examples/view/template_blocks_2/src/public/html/files/list.html: -------------------------------------------------------------------------------- 1 | {{ define "title"}} 2 | 222 3 | {{ end }} 4 | 5 | {{ define "content" }} 6 |

    List Content

    7 | {{ end }} -------------------------------------------------------------------------------- /_examples/view/template_blocks_2/src/public/html/layouts/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ block "title" .}}Main Default Title{{end}} 4 | 5 | 6 | {{ block "content" .}}

    Main Default Content

    {{end}} 7 | 8 | -------------------------------------------------------------------------------- /_examples/view/template_blocks_2/src/public/html/layouts/secondary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ block "title" .}}Secondary Default Title{{end}} 4 | 5 | 6 |

    Secondary Layout

    7 | {{ block "content" .}}

    Secondary Default Content

    {{end}} 8 | 9 | -------------------------------------------------------------------------------- /_examples/view/template_blocks_2/src/public/html/menu/menu.html: -------------------------------------------------------------------------------- 1 | {{ define "title" }} 111{{ end }} 2 | 3 | {{ define "content" }}

    Menu Content

    {{ end }} -------------------------------------------------------------------------------- /_examples/view/template_django_0/templates/hi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{title}} 4 | 5 | 6 |

    Hi {{name|capfirst}}

    7 | 8 |

    {{greet(name)}}

    9 | 10 |

    Server started about {{serverStartTime|timesince}}. Refresh the page to see different result

    11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/template_handlebars_0/templates/example.html: -------------------------------------------------------------------------------- 1 |
    2 |

    By {{fullName author}}

    3 |
    {{body}}
    4 | 5 |

    Comments

    6 | 7 | {{#each comments}} 8 |

    By {{fullName author}}

    9 |
    {{body}}
    10 | {{/each}} 11 | 12 | 13 | 19 | 20 |
    21 | 22 | Read more at: 23 | https://github.com/mailgun/raymond and 24 | https://handlebarsjs.com/guide 25 | 26 | 27 |
    -------------------------------------------------------------------------------- /_examples/view/template_html_0/templates/hi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{.Title}} 4 | 5 | 6 |

    Hi {{.Name}}

    7 | 8 | 9 | -------------------------------------------------------------------------------- /_examples/view/template_html_1/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | My Layout 4 | 5 | 6 | 7 |

    [layout] Body content is below...

    8 | 9 | {{ yield . }} 10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/view/template_html_1/templates/mypage.html: -------------------------------------------------------------------------------- 1 |

    2 | Title: {{.Title}} 3 |

    4 |

    Message: {{.Message}}

    -------------------------------------------------------------------------------- /_examples/view/template_html_2/README.md: -------------------------------------------------------------------------------- 1 | ## Info 2 | 3 | This folder examines the {{render "dir/templatefilename" .}} functionality to manually render any template inside any template 4 | -------------------------------------------------------------------------------- /_examples/view/template_html_2/templates/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Layout 4 | 5 | 6 | 7 |

    This is the global layout

    8 |
    9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/template_html_2/templates/layouts/mylayout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | my Layout 4 | 5 | 6 | 7 |

    This is the layout for the /my/ and /my/other routes only

    8 |
    9 | 10 | {{ yield . }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /_examples/view/template_html_2/templates/page1.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |

    Page 1 {{ greet "iris developer"}}

    4 | 5 | {{ render "partials/page1_partial1.html" . }} 6 | 7 |
    8 | -------------------------------------------------------------------------------- /_examples/view/template_html_2/templates/partials/page1_partial1.html: -------------------------------------------------------------------------------- 1 |
    2 |

    Page 1's Partial 1

    3 |
    4 | -------------------------------------------------------------------------------- /_examples/view/template_html_5/views/about.html: -------------------------------------------------------------------------------- 1 | {{ define "about-head"}} 2 | about page 3 | 8 | {{ end }} 9 | 10 | {{ define "about-body"}} 11 | extend body content in layout. 12 | {{ end }} 13 |
    14 | Hello about page 15 |
    -------------------------------------------------------------------------------- /_examples/view/template_html_5/views/home.html: -------------------------------------------------------------------------------- 1 | {{ define "home-head"}} 2 | {{.title}} 3 | 8 | {{ end }} 9 |
    10 | Hello home page 11 |
    -------------------------------------------------------------------------------- /_examples/view/template_html_5/views/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ part "head"}} 4 | 5 | 6 |

    [layout] Body content is below...

    7 | {{ part "body" . }} 8 | 9 | {{ yield . }} 10 | 11 | 12 | -------------------------------------------------------------------------------- /_examples/view/template_html_5/views/user/index.html: -------------------------------------------------------------------------------- 1 | {{ define "user/index-head"}} 2 | 7 | {{ end }} 8 |
    9 | Hello user index page 10 |
    -------------------------------------------------------------------------------- /_examples/view/template_jet_0/README.md: -------------------------------------------------------------------------------- 1 | # Jet Engine Example 2 | 3 | This example is a fork of to work with Iris, so you can notice the differences side by side. 4 | 5 | Read more at: https://github.com/CloudyKit/jet/blob/master/docs/syntax.md 6 | 7 | > The Iris Jet View Engine fixes some bugs that the underline [jet template parser](https://github.com/CloudyKit/jet) currently has. 8 | 9 | 10 | Continue by learning how you can [serve embedded templates](../template_jet_1_embedded). -------------------------------------------------------------------------------- /_examples/view/template_jet_0/views/layouts/application.jet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ isset(title) ? title : "Default" }} 6 | 7 | 8 | {{block documentBody()}}{{end}} 9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/view/template_jet_0/views/todos/show.jet: -------------------------------------------------------------------------------- 1 | {{extends "../layouts/application.jet"}} 2 | 3 | {{block documentBody()}} 4 |

    Show TODO

    5 |

    This uses a custom renderer by implementing the Renderer interface. 6 |

    7 | {{.}} 8 |

    9 | {{end}} 10 | -------------------------------------------------------------------------------- /_examples/view/template_jet_1_embedded/views/includes/_partial.jet: -------------------------------------------------------------------------------- 1 |

    Included partial

    2 | -------------------------------------------------------------------------------- /_examples/view/template_jet_1_embedded/views/includes/blocks.jet: -------------------------------------------------------------------------------- 1 | {{block menu()}} 2 |

    The menu block was invoked.

    3 | {{end}} 4 | -------------------------------------------------------------------------------- /_examples/view/template_jet_1_embedded/views/index.jet: -------------------------------------------------------------------------------- 1 | {{extends "layouts/application.jet"}} 2 | {{import "includes/blocks.jet"}} 3 | 4 | {{block documentBody()}} 5 |

    Embedded example

    6 | 7 | 10 | 11 | {{include "includes/_partial.jet"}} 12 | 13 | {{if !includeIfExists("doesNotExist.jet")}} 14 |

    Shows how !includeIfExists works: doesNotExist.jet was not included because it doesn't exist.

    15 | {{end}} 16 | {{end}} 17 | -------------------------------------------------------------------------------- /_examples/view/template_jet_1_embedded/views/layouts/application.jet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Embedded example 6 | 7 | 8 | {{block documentBody()}}{{end}} 9 | 10 | 11 | -------------------------------------------------------------------------------- /_examples/view/template_jet_3/views/index.jet: -------------------------------------------------------------------------------- 1 | {{ asset("./myasset.mp3")}} 2 |
    3 | {{ style("my-stle.css") | raw}} 4 |
    5 | {{ script("my-script.js") | raw}} 6 | 7 | 9 | 10 | 11 | ./myasset.mp3 12 |
    13 | <link href="my-stle.css" rel="stylesheet"> 14 |
    15 | <script src="my-script.js"></script> 16 |
    -------------------------------------------------------------------------------- /_examples/view/template_pug_0/templates/index.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html(lang="en") 3 | head 4 | meta(charset="utf-8") 5 | title Title 6 | body 7 | p ads 8 | ul 9 | li The name is {{.Name}}. 10 | li The age is {{.Age}}. 11 | 12 | each _,_ in .Emails 13 | div An email is {{.}} 14 | 15 | | {{ with .Jobs }} 16 | each _,_ in . 17 | div 18 | An employer is {{.Employer}} 19 | and the role is {{.Role}} 20 | | {{ end }} -------------------------------------------------------------------------------- /_examples/view/template_pug_1/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "html/template" 6 | 7 | "github.com/kataras/iris/v12" 8 | ) 9 | 10 | func main() { 11 | app := iris.New() 12 | 13 | tmpl := iris.Pug("./templates", ".pug") 14 | tmpl.Reload(true) // reload templates on each request (development mode) 15 | tmpl.AddFunc("bold", func(s string) (template.HTML, error) { // add your template func here. 16 | return template.HTML("" + s + ""), nil 17 | }) 18 | 19 | app.RegisterView(tmpl) 20 | 21 | app.Get("/", index) 22 | 23 | // http://localhost:8080 24 | app.Listen(":8080") 25 | } 26 | 27 | func index(ctx iris.Context) { 28 | if err := ctx.View("index.pug"); err != nil { 29 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 30 | return 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_examples/view/template_pug_1/templates/footer.pug: -------------------------------------------------------------------------------- 1 | #footer 2 | p Copyright (c) foobar -------------------------------------------------------------------------------- /_examples/view/template_pug_1/templates/header.pug: -------------------------------------------------------------------------------- 1 | head 2 | title My Site 3 | -------------------------------------------------------------------------------- /_examples/view/template_pug_1/templates/index.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | include header.pug 4 | body 5 | h1 My Site 6 | p {{ bold "Welcome to my super lame site."}} 7 | include footer.pug -------------------------------------------------------------------------------- /_examples/view/template_pug_2_embedded/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | // $ go install github.com/go-bindata/go-bindata/v3/go-bindata@latest 10 | // 11 | // $ go-bindata -fs -prefix "templates" ./templates/... 12 | // $ go run . 13 | // 14 | // System files are not used, you can optionally delete the folder and run the example now. 15 | func main() { 16 | app := iris.New() 17 | 18 | tmpl := iris.Pug(AssetFile(), ".pug") 19 | 20 | app.RegisterView(tmpl) 21 | 22 | app.Get("/", index) 23 | 24 | // http://localhost:8080 25 | app.Listen(":8080") 26 | } 27 | 28 | func index(ctx iris.Context) { 29 | if err := ctx.View("index.pug"); err != nil { 30 | ctx.HTML(fmt.Sprintf("

    %s

    ", err.Error())) 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /_examples/view/template_pug_2_embedded/templates/index.pug: -------------------------------------------------------------------------------- 1 | extends layout.pug 2 | 3 | block title 4 | title Article Title 5 | 6 | block content 7 | h1 My Article -------------------------------------------------------------------------------- /_examples/view/template_pug_2_embedded/templates/layout.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | block title 5 | title Default title 6 | body 7 | block content -------------------------------------------------------------------------------- /_examples/view/write-to/views/email/simple.html: -------------------------------------------------------------------------------- 1 | {{.Body}} -------------------------------------------------------------------------------- /_examples/view/write-to/views/shared/email.html: -------------------------------------------------------------------------------- 1 |

    {{.Title}}

    2 |

    3 | {{yield}} 4 |

    5 | 6 | {{.RefTitle}} 7 | -------------------------------------------------------------------------------- /_examples/webassembly/client/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello Webassembly + Iris (Go) 5 | 6 | 7 |
    8 | 9 | 10 | -------------------------------------------------------------------------------- /_examples/webassembly/client/hello_go116.go: -------------------------------------------------------------------------------- 1 | //go:build js 2 | // +build js 3 | 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "syscall/js" 9 | "time" 10 | ) 11 | 12 | func main() { 13 | // GOARCH=wasm GOOS=js /home/$yourusername/go1.16/bin/go build -mod=mod -o hello.wasm hello_go116.go 14 | js.Global().Get("console").Call("log", "Hello Webassembly!") 15 | message := fmt.Sprintf("Hello, the current time is: %s", time.Now().String()) 16 | js.Global().Get("document").Call("getElementById", "hello").Set("innerText", message) 17 | } 18 | -------------------------------------------------------------------------------- /_examples/webassembly/client/main.js: -------------------------------------------------------------------------------- 1 | import './go-wasm-runtime.js'; 2 | 3 | if (!WebAssembly.instantiateStreaming) { // polyfill 4 | WebAssembly.instantiateStreaming = async (resp, importObject) => { 5 | const source = await (await resp).arrayBuffer(); 6 | return await WebAssembly.instantiate(source, importObject); 7 | }; 8 | } 9 | 10 | const go = new Go(); 11 | WebAssembly.instantiateStreaming(fetch("hello.wasm"), go.importObject).then((result) => { 12 | return WebAssembly.instantiate(result.module, go.importObject); 13 | }).then(instance => go.run(instance)); -------------------------------------------------------------------------------- /_examples/websocket/basic/browserify/client.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
    
     9 | 
    10 | 
    11 | 
    
    
    --------------------------------------------------------------------------------
    /_examples/websocket/basic/browserify/package.json:
    --------------------------------------------------------------------------------
     1 | {
     2 |     "name": "neffos.js.example.browserify",
     3 |     "version": "0.0.1",
     4 |     "scripts": {
     5 |         "browserify": "browserify ./app.js -o ./bundle.js",
     6 |         "minifyES6": "minify ./bundle.js --outFile ./bundle.js",
     7 |         "build": "npm run-script browserify && npm run-script minifyES6"
     8 |     },
     9 |     "dependencies": {
    10 |         "neffos.js": "latest"
    11 |     },
    12 |     "devDependencies": {
    13 |         "browserify": "^16.2.3",
    14 |         "babel-minify": "^0.5.0"
    15 |     }
    16 | }
    17 | 
    
    
    --------------------------------------------------------------------------------
    /_examples/websocket/basic/nodejs-client/package.json:
    --------------------------------------------------------------------------------
    1 | {
    2 |     "name": "neffos.js.example.nodejsclient",
    3 |     "version": "0.0.1",
    4 |     "main": "client.js",
    5 |     "dependencies": {
    6 |         "neffos.js": "latest"
    7 |     }
    8 | }
    9 | 
    
    
    --------------------------------------------------------------------------------
    /_examples/websocket/basic/overview.png:
    --------------------------------------------------------------------------------
    https://raw.githubusercontent.com/kataras/iris/de4f462198bfc681d7b0072f57915c1316fad7c9/_examples/websocket/basic/overview.png
    
    
    --------------------------------------------------------------------------------
    /_examples/websocket/gorilla-filewatch/testfile.txt:
    --------------------------------------------------------------------------------
    1 | Some Contents
    2 | # you can edit this file locally
    3 | # and http://localhost:8080
    4 | # will render the new contents through the live websocket connection.
    
    
    --------------------------------------------------------------------------------
    /_examples/websocket/native-messages/templates/client.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 	{{ .Title}}
     5 | 
     6 | 
     7 | 
     8 | 	
     9 | 	
    10 | 	
    11 |
    12 | 13 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /_examples/websocket/online-visitors/templates/other.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Different page, different results 5 | 11 | 12 | 13 | 14 | 15 | 1 online view 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /_examples/websocket/secure/README.md: -------------------------------------------------------------------------------- 1 | # Secure Websockets 2 | 3 | 1. Run your server through `https://` (`iris.Run(iris.TLS)` or `iris.Run(iris.AutoTLS)` or a custom `iris.Listener(...)`) 4 | 2. Nothing changes inside the whole app, including the websocket side 5 | 3. The clients must dial the websocket server endpoint (i.e `/echo`) via `wss://` prefix (instead of the non-secure `ws://`), for example `wss://example.com/echo` 6 | 4. Ready to GO. 7 | -------------------------------------------------------------------------------- /apps/switch_scheme.go: -------------------------------------------------------------------------------- 1 | package apps 2 | -------------------------------------------------------------------------------- /cache/client/rule/not_satisfied.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/context" 5 | ) 6 | 7 | type notSatisfiedRule struct{} 8 | 9 | var _ Rule = ¬SatisfiedRule{} 10 | 11 | // NotSatisfied returns a rule which allows nothing 12 | func NotSatisfied() Rule { 13 | return ¬SatisfiedRule{} 14 | } 15 | 16 | func (n *notSatisfiedRule) Claim(*context.Context) bool { 17 | return false 18 | } 19 | 20 | func (n *notSatisfiedRule) Valid(*context.Context) bool { 21 | return false 22 | } 23 | -------------------------------------------------------------------------------- /cache/client/rule/rule.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import "github.com/kataras/iris/v12/context" 4 | 5 | // Rule a superset of validators 6 | type Rule interface { 7 | Claim(ctx *context.Context) bool 8 | Valid(ctx *context.Context) bool 9 | } 10 | -------------------------------------------------------------------------------- /cache/client/rule/satisfied.go: -------------------------------------------------------------------------------- 1 | package rule 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/context" 5 | ) 6 | 7 | type satisfiedRule struct{} 8 | 9 | var _ Rule = &satisfiedRule{} 10 | 11 | // Satisfied returns a rule which allows anything, 12 | // it's usually the last rule on chained rules if no next rule is given, 13 | // but it can be used outside of a chain too as a default allow-all rule. 14 | func Satisfied() Rule { 15 | return &satisfiedRule{} 16 | } 17 | 18 | func (n *satisfiedRule) Claim(*context.Context) bool { 19 | return true 20 | } 21 | 22 | func (n *satisfiedRule) Valid(*context.Context) bool { 23 | return true 24 | } 25 | -------------------------------------------------------------------------------- /context/context_go118.go: -------------------------------------------------------------------------------- 1 | //go:build go1.18 2 | // +build go1.18 3 | 4 | package context 5 | 6 | import "runtime/debug" 7 | 8 | func init() { 9 | if info, ok := debug.ReadBuildInfo(); ok { 10 | for _, setting := range info.Settings { 11 | if BuildRevision != "" && BuildTime != "" { 12 | break 13 | } 14 | 15 | if setting.Key == "vcs.revision" { 16 | BuildRevision = setting.Value 17 | } 18 | 19 | if setting.Key == "vcs.time" { 20 | BuildTime = setting.Value 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/netutil/client.go: -------------------------------------------------------------------------------- 1 | package netutil 2 | 3 | import ( 4 | "net" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/kataras/golog" 9 | ) 10 | 11 | // Client returns a new http.Client using 12 | // the "timeout" for open connection. 13 | func Client(timeout time.Duration) *http.Client { 14 | transport := http.Transport{ 15 | Dial: func(network string, addr string) (net.Conn, error) { 16 | conn, err := net.DialTimeout(network, addr, timeout) 17 | if err != nil { 18 | golog.Debugf("%v", err) 19 | return nil, err 20 | } 21 | return conn, err 22 | }, 23 | } 24 | 25 | client := &http.Client{ 26 | Transport: &transport, 27 | } 28 | 29 | return client 30 | } 31 | -------------------------------------------------------------------------------- /core/netutil/tcp_soreuse_control_unix.go: -------------------------------------------------------------------------------- 1 | //go:build !windows && !wasm 2 | // +build !windows,!wasm 3 | 4 | package netutil 5 | 6 | import ( 7 | "syscall" 8 | 9 | "golang.org/x/sys/unix" 10 | ) 11 | 12 | func control(network, address string, c syscall.RawConn) (err error) { 13 | c.Control(func(fd uintptr) { 14 | err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1) 15 | if err != nil { 16 | return 17 | } 18 | 19 | err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1) 20 | if err != nil { 21 | return 22 | } 23 | }) 24 | 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /core/netutil/tcp_soreuse_control_wasm.go: -------------------------------------------------------------------------------- 1 | //go:build wasm 2 | // +build wasm 3 | 4 | package netutil 5 | 6 | import "syscall" 7 | 8 | func control(network, address string, c syscall.RawConn) error { 9 | return nil 10 | } 11 | -------------------------------------------------------------------------------- /core/netutil/tcp_soreuse_control_windows.go: -------------------------------------------------------------------------------- 1 | package netutil 2 | 3 | import ( 4 | "syscall" 5 | 6 | "golang.org/x/sys/windows" 7 | ) 8 | 9 | func control(network, address string, c syscall.RawConn) (err error) { 10 | return c.Control(func(fd uintptr) { 11 | err = windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_REUSEADDR, 1) 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /httptest/aliases.go: -------------------------------------------------------------------------------- 1 | package httptest 2 | 3 | import "github.com/iris-contrib/httpexpect/v2" 4 | 5 | type ( 6 | // Request type alias. 7 | Request = httpexpect.Request 8 | // Expect type alias. 9 | Expect = httpexpect.Expect 10 | ) 11 | -------------------------------------------------------------------------------- /httptest/server.go: -------------------------------------------------------------------------------- 1 | package httptest 2 | 3 | import ( 4 | "net/http/httptest" 5 | 6 | "github.com/kataras/iris/v12" 7 | ) 8 | 9 | // NewServer is just a helper to create a new standard 10 | // httptest.Server instance. 11 | func NewServer(t IrisTesty, app *iris.Application) *httptest.Server { 12 | if err := app.Build(); err != nil { 13 | t.Fatal(err) 14 | return nil 15 | } 16 | 17 | return httptest.NewServer(app) 18 | } 19 | -------------------------------------------------------------------------------- /i18n/internal/aliases.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | // Map is just an alias of the map[string]interface{} type. 4 | // Just like the iris.Map one. 5 | type Map = map[string]interface{} 6 | -------------------------------------------------------------------------------- /middleware/jwt/jwt.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | import "github.com/kataras/iris/v12/context" 4 | 5 | func init() { 6 | context.SetHandlerName("iris/middleware/jwt.*", "iris.jwt") 7 | } 8 | -------------------------------------------------------------------------------- /middleware/monitor/expvar_uint64.go: -------------------------------------------------------------------------------- 1 | package monitor 2 | 3 | import ( 4 | "expvar" 5 | "strconv" 6 | "sync/atomic" 7 | ) 8 | 9 | // Uint64 completes the expvar metric interface, holds an uint64 value. 10 | type Uint64 struct { 11 | value uint64 12 | } 13 | 14 | // Set sets v to value. 15 | func (v *Uint64) Set(value uint64) { 16 | atomic.StoreUint64(&v.value, value) 17 | } 18 | 19 | // Value returns the underline uint64 value. 20 | func (v *Uint64) Value() uint64 { 21 | return atomic.LoadUint64(&v.value) 22 | } 23 | 24 | // String returns the text representation of the underline uint64 value. 25 | func (v *Uint64) String() string { 26 | return strconv.FormatUint(atomic.LoadUint64(&v.value), 10) 27 | } 28 | 29 | func newUint64(name string) *Uint64 { 30 | v := new(Uint64) 31 | expvar.Publish(name, v) 32 | return v 33 | } 34 | -------------------------------------------------------------------------------- /x/errors/aliases.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | var ( 9 | // Is is an alias of the standard errors.Is function. 10 | Is = errors.Is 11 | // As is an alias of the standard errors.As function. 12 | As = errors.As 13 | // New is an alias of the standard errors.New function. 14 | New = errors.New 15 | // Unwrap is an alias of the standard errors.Unwrap function. 16 | Unwrap = errors.Unwrap 17 | // Join is an alias of the standard errors.Join function. 18 | Join = errors.Join 19 | ) 20 | 21 | func sprintf(format string, args ...interface{}) string { 22 | if len(args) > 0 { 23 | return fmt.Sprintf(format, args...) 24 | } 25 | 26 | return format 27 | } 28 | -------------------------------------------------------------------------------- /x/errors/context_error_handler.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import "github.com/kataras/iris/v12/context" 4 | 5 | // DefaultContextErrorHandler returns a context error handler 6 | // which calls the HandleError on any incoming error when 7 | // a rich rest response failed to be written to the client. 8 | // Register it on Application.SetContextErrorHandler method. 9 | var DefaultContextErrorHandler context.ErrorHandler = new(jsonErrorHandler) 10 | 11 | type jsonErrorHandler struct{} 12 | 13 | // HandleContextError completes the context.ErrorHandler interface. It's fired on 14 | // rich rest response failures. 15 | func (e *jsonErrorHandler) HandleContextError(ctx *context.Context, err error) { 16 | HandleError(ctx, err) 17 | } 18 | -------------------------------------------------------------------------------- /x/errors/path_parameter_type_error_handler.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "github.com/kataras/iris/v12/context" 5 | "github.com/kataras/iris/v12/macro/handler" 6 | ) 7 | 8 | // DefaultPathParameterTypeErrorHandler registers an error handler for macro path type parameter. 9 | // Register it with Application.Macros().SetErrorHandler(DefaultPathParameterTypeErrorHandler). 10 | var DefaultPathParameterTypeErrorHandler handler.ParamErrorHandler = func(ctx *context.Context, paramIndex int, err error) { 11 | param := ctx.Params().GetEntryAt(paramIndex) // key, value fields. 12 | InvalidArgument.DataWithDetails(ctx, "invalid path parameter", err.Error(), param) 13 | } 14 | -------------------------------------------------------------------------------- /x/jsonx/exampler.go: -------------------------------------------------------------------------------- 1 | package jsonx 2 | 3 | // Exampler is an interface used by testing to generate examples. 4 | type Exampler interface { 5 | ListExamples() any 6 | } 7 | -------------------------------------------------------------------------------- /x/jsonx/jsonx.go: -------------------------------------------------------------------------------- 1 | package jsonx 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | ) 7 | 8 | var ( 9 | quoteLiteral = '"' 10 | emptyQuoteBytes = []byte(`""`) 11 | nullLiteral = []byte("null") 12 | 13 | // ErrInvalid is returned when the value is invalid. 14 | ErrInvalid = errors.New("invalid") 15 | ) 16 | 17 | func isNull(b []byte) bool { 18 | return len(b) == 0 || bytes.Equal(b, nullLiteral) 19 | } 20 | 21 | func trimQuotesFunc(r rune) bool { 22 | return r == quoteLiteral 23 | } 24 | 25 | func trimQuotes(b []byte) []byte { 26 | return bytes.TrimFunc(b, trimQuotesFunc) 27 | } 28 | -------------------------------------------------------------------------------- /x/reflex/error.go: -------------------------------------------------------------------------------- 1 | package reflex 2 | 3 | import "reflect" 4 | 5 | // IsError reports whether "typ" is an error type. 6 | func IsError(typ interface{ Implements(reflect.Type) bool }) bool { 7 | return typ.Implements(ErrTyp) 8 | } 9 | -------------------------------------------------------------------------------- /x/reflex/reflex.go: -------------------------------------------------------------------------------- 1 | package reflex 2 | 3 | import "reflect" 4 | 5 | // IndirectType returns the value of a pointer-type "typ". 6 | // If "IndirectType" is a pointer, array, chan, map or slice it returns its Elem, 7 | // otherwise returns the "typ" as it is. 8 | func IndirectType(typ reflect.Type) reflect.Type { 9 | switch typ.Kind() { 10 | case reflect.Ptr, reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: 11 | return typ.Elem() 12 | } 13 | return typ 14 | } 15 | 16 | // IndirectValue returns the element type (e.g. if pointer of *User it will return the User type). 17 | func IndirectValue(val reflect.Value) reflect.Value { 18 | return reflect.Indirect(val) 19 | } 20 | --------------------------------------------------------------------------------