github.com/boomhut/fiber/v2@v2.0.0-20230603160335-b65c856e57d3/.github/README_zh-TW.md (about) 1 <p align="center"> 2 <a href="https://gofiber.io"> 3 4 <picture> 5 <source height="125" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/gofiber/docs/master/static/img/logo-dark.svg"> 6 <img height="125" alt="Fiber" src="https://raw.githubusercontent.com/gofiber/docs/master/static/img/logo.svg"> 7 </picture> 8 9 </a> 10 <br> 11 <!-- base64 flags are available at https://www.phoca.cz/cssflags/ --> 12 <a href="https://github.com/gofiber/fiber/blob/master/.github/README.md"> 13 <img height="20px" src="https://img.shields.io/badge/EN-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgNjAgMzAiIGhlaWdodD0iNjAwIj4NCjxkZWZzPg0KPGNsaXBQYXRoIGlkPSJ0Ij4NCjxwYXRoIGQ9Im0zMCwxNWgzMHYxNXp2MTVoLTMwemgtMzB2LTE1enYtMTVoMzB6Ii8+DQo8L2NsaXBQYXRoPg0KPC9kZWZzPg0KPHBhdGggZmlsbD0iIzAwMjQ3ZCIgZD0ibTAsMHYzMGg2MHYtMzB6Ii8+DQo8cGF0aCBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iNiIgZD0ibTAsMGw2MCwzMG0wLTMwbC02MCwzMCIvPg0KPHBhdGggc3Ryb2tlPSIjY2YxNDJiIiBzdHJva2Utd2lkdGg9IjQiIGQ9Im0wLDBsNjAsMzBtMC0zMGwtNjAsMzAiIGNsaXAtcGF0aD0idXJsKCN0KSIvPg0KPHBhdGggc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjEwIiBkPSJtMzAsMHYzMG0tMzAtMTVoNjAiLz4NCjxwYXRoIHN0cm9rZT0iI2NmMTQyYiIgc3Ryb2tlLXdpZHRoPSI2IiBkPSJtMzAsMHYzMG0tMzAtMTVoNjAiLz4NCjwvc3ZnPg0K"> 14 </a> 15 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_ru.md"> 16 <img height="20px" src="https://img.shields.io/badge/RU-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NTAgMzAwIj4NCjxwYXRoIGZpbGw9IiNmZmYiIGQ9Im0wLDBoNDUwdjEwMGgtNDUweiIvPg0KPHBhdGggZmlsbD0iIzAwZiIgZD0ibTAsMTAwaDQ1MHYxMDBoLTQ1MHoiLz4NCjxwYXRoIGZpbGw9IiNmMDAiIGQ9Im0wLDIwMGg0NTB2MTAwaC00NTB6Ii8+DQo8L3N2Zz4NCg=="> 17 </a> 18 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_es.md"> 19 <img height="20px" src="https://img.shields.io/badge/ES-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3NTAgNTAwIj4NCjxwYXRoIGZpbGw9IiNjNjBiMWUiIGQ9Im0wLDBoNzUwdjUwMGgtNzUweiIvPg0KPHBhdGggZmlsbD0iI2ZmYzQwMCIgZD0ibTAsMTI1aDc1MHYyNTBoLTc1MHoiLz4NCjwvc3ZnPg0K"> 20 </a> 21 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_ja.md"> 22 <img height="20px" src="https://img.shields.io/badge/JA-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA5MDAgNjAwIj4NCjxwYXRoIGZpbGw9IiNmZmYiIGQ9Im0wLDBoOTAwdjYwMGgtOTAweiIvPg0KPGNpcmNsZSBmaWxsPSIjYmUwMDI2IiBjeD0iNDUwIiBjeT0iMzAwIiByPSIxODAiLz4NCjwvc3ZnPg0K"> 23 </a> 24 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_pt.md"> 25 <img height="20px" src="https://img.shields.io/badge/PT-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDUxMiA1MTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHJlY3QgeT0iODUuMzM3IiBzdHlsZT0iZmlsbDojRDgwMDI3OyIgd2lkdGg9IjUxMiIgaGVpZ2h0PSIzNDEuMzI2Ii8+Cjxwb2x5Z29uIHN0eWxlPSJmaWxsOiM2REE1NDQ7IiBwb2ludHM9IjE5Ni42NDEsODUuMzM3IDE5Ni42NDEsMjYxLjU2NSAxOTYuNjQxLDQyNi42NjMgMCw0MjYuNjYzIDAsODUuMzM3ICIvPgo8Y2lyY2xlIHN0eWxlPSJmaWxsOiNGRkRBNDQ7IiBjeD0iMTk2LjY0MSIgY3k9IjI1NiIgcj0iNjQiLz4KPHBhdGggc3R5bGU9ImZpbGw6I0Q4MDAyNzsiIGQ9Ik0xNjAuNjM4LDIyNHY0MC4wMDFjMCwxOS44ODIsMTYuMTE4LDM2LDM2LDM2czM2LTE2LjExOCwzNi0zNlYyMjRIMTYwLjYzOHoiLz4KPHBhdGggc3R5bGU9ImZpbGw6I0YwRjBGMDsiIGQ9Ik0xOTYuNjM4LDI3NmMtNi42MTcsMC0xMi01LjM4My0xMi0xMnYtMTZoMjQuMDAxdjE2QzIwOC42MzgsMjcwLjYxNiwyMDMuMjU0LDI3NiwxOTYuNjM4LDI3NnoiLz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg=="> 26 </a> 27 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_zh-CN.md"> 28 <img height="20px" src="https://img.shields.io/badge/CN-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAwIDgwMCIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPg0KPHBhdGggZmlsbD0iI2RlMjkxMCIgZD0ibTAsMGgxMjAwdjgwMGgtMTIwMHoiLz4NCjxwYXRoIGZpbGw9IiNmZmRlMDAiIGQ9Im0tMTYuNTc5Niw5OS42MDA3bDIuMzY4Ni04LjEwMzItNi45NTMtNC43ODgzIDguNDM4Ni0uMjUxNCAyLjQwNTMtOC4wOTI0IDIuODQ2Nyw3Ljk0NzkgOC40Mzk2LS4yMTMxLTYuNjc5Miw1LjE2MzQgMi44MTA2LDcuOTYwNy02Ljk3NDctNC43NTY3LTYuNzAyNSw1LjEzMzF6IiB0cmFuc2Zvcm09Im1hdHJpeCg5LjkzMzUyIC4yNzc0NyAtLjI3NzQ3IDkuOTMzNTIgMzI0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.shields.io/badge/TW-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjwhRE9DVFlQRSBzdmc+DQo8c3ZnIHdpZHRoPSI5MDAiIGhlaWdodD0iNjAwIiB2aWV3Qm94PSItNjAgLTQwIDI0MCAxNjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPg0KICAgPHJlY3QgeD0iLTYwIiB5PSItNDAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9IiNmZTAwMDAiLz4NCiAgIDxyZWN0IHg9Ii02MCIgeT0iLTQwIiB3aWR0aD0iNTAlIiBoZWlnaHQ9IjUwJSIgZmlsbD0iIzAwMDA5NSIvPg0KICAgPHBhdGggaWQ9ImZvdXJfcmF5cyIgZD0iTSA4LDAgTCAwLDMwIEwgLTgsMCBMIDAsLTMwIE0gMCw4IEwgMzAsMCBMIDAsLTggTCAtMzAsMCIgZmlsbD0iI2ZmZiIvPg0KICAgPHVzZSB4bGluazpocmVmPSIjZm91cl9yYXlzIiB0cmFuc2Zvcm09InJvdGF0ZSgzMCkiLz4NCiAgIDx1c2UgeGxpbms6aHJlZj0iI2ZvdXJfcmF5cyIgdHJhbnNmb3JtPSJyb3RhdGUoNjApIi8+DQogICA8Y2lyY2xlIHI9IjE3IiBmaWxsPSIjMDAwMDk1Ii8+DQogICA8Y2lyY2xlIHI9IjE1IiBmaWxsPSIjZmZmIi8+DQo8L3N2Zz4="> 32 </a> --> 33 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_de.md"> 34 <img height="20px" src="https://img.shields.io/badge/DE-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBoZWlnaHQ9IjYwMCIgdmlld0JveD0iMCAwIDUgMyI+DQo8cGF0aCBkPSJtMCwwaDV2M2gtNXoiLz4NCjxwYXRoIGZpbGw9IiNkMDAiIGQ9Im0wLDFoNXYyaC01eiIvPg0KPHBhdGggZmlsbD0iI2ZmY2UwMCIgZD0ibTAsMmg1djFoLTV6Ii8+DQo8L3N2Zz4NCg=="> 35 </a> 36 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_nl.md"> 37 <img height="20px" src="https://img.shields.io/badge/NL-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNjAwIiB2aWV3Qm94PSIwIDAgOSA2Ij4NCjxwYXRoIGZpbGw9IiMyMTQ2OGIiIGQ9Im0wLDBoOXY2aC05eiIvPg0KPHBhdGggZmlsbD0iI2ZmZiIgZD0ibTAsMGg5djRoLTl6Ii8+DQo8cGF0aCBmaWxsPSIjYWUxYzI4IiBkPSJtMCwwaDl2MmgtOXoiLz4NCjwvc3ZnPg0K"> 38 </a> 39 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_ko.md"> 40 <img height="20px" src="https://img.shields.io/badge/KO-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNjAwIiB2aWV3Qm94PSItMzYgLTI0IDcyIDQ4IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+DQo8cGF0aCBmaWxsPSIjZmZmIiBkPSJtLTM2LTI0aDcydjQ4aC03MnoiLz4NCjxnIHRyYW5zZm9ybT0ibWF0cml4KC41NTQ3IC0uODMyMDUgLjgzMjA1IC41NTQ3IDAgMCkiPg0KPGcgaWQ9ImIyIj4NCjxwYXRoIHN0cm9rZT0iIzAwMCIgaWQ9ImIiIHN0cm9rZS13aWR0aD0iMiIgZD0iTS02LTI1SDZNLTYtMjJINk0tNi0xOUg2Ii8+DQo8dXNlIHk9IjQ0IiB4bGluazpocmVmPSIjYiIvPg0KPC9nPg0KPHBhdGggc3Ryb2tlPSIjZmZmIiBkPSJtMCwxN3YxMCIvPg0KPGNpcmNsZSBmaWxsPSIjYzYwYzMwIiByPSIxMiIvPg0KPHBhdGggZmlsbD0iIzAwMzQ3OCIgZD0iTTAtMTJBNiw2IDAgMCAwIDAsMEE2LDYgMCAwIDEgMCwxMkExMiwxMiAwIDAsMSAwLTEyWiIvPg0KPC9nPg0KPGcgdHJhbnNmb3JtPSJtYXRyaXgoLS41NTQ3IC0uODMyMDUgLjgzMjA1IC0uNTU0NyAwIDApIj4NCjx1c2UgeGxpbms6aHJlZj0iI2IyIi8+DQo8cGF0aCBzdHJva2U9IiNmZmYiIGQ9Im0wLTIzLjV2M20wLDM3LjV2My41bTAsM3YzIi8+DQo8L2c+DQo8L3N2Zz4NCg=="> 41 </a> 42 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_fr.md"> 43 <img height="20px" src="https://img.shields.io/badge/FR-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA5MDAgNjAwIj4NCjxwYXRoIGZpbGw9IiNlZDI5MzkiIGQ9Im0wLDBoOTAwdjYwMGgtOTAweiIvPg0KPHBhdGggZmlsbD0iI2ZmZiIgZD0ibTAsMGg2MDB2NjAwaC02MDB6Ii8+DQo8cGF0aCBmaWxsPSIjMDAyMzk1IiBkPSJtMCwwaDMwMHY2MDBoLTMwMHoiLz4NCjwvc3ZnPg0K"> 44 </a> 45 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_tr.md"> 46 <img height="20px" src="https://img.shields.io/badge/TR-flag.svg?color=555555&style=flat-square&logo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="https://github.com/gofiber/fiber/blob/master/.github/README_id.md"> 49 <img height="20px" src="https://img.shields.io/badge/ID-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MDAgNDAwIj4NCjxwYXRoIGZpbGw9IiNjZTExMjYiIGQ9Im0wLDBoNjAwdjIwMGgtNjAweiIvPg0KPHBhdGggZmlsbD0iI2ZmZiIgZD0ibTAsMjAwaDYwMHYyMDBoLTYwMHoiLz4NCjwvc3ZnPg0K"> 50 </a> 51 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_he.md"> 52 <img height="20px" src="https://img.shields.io/badge/HE-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjYwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNDgwIiB2aWV3Qm94PSIwIDAgMjIwIDE2MCIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPg0KPGRlZnM+DQo8cGF0aCBzdHJva2U9IiMwMDM4YjgiIGZpbGwtb3BhY2l0eT0iMCIgaWQ9InRyaWFuZ2xlIiBzdHJva2Utd2lkdGg9IjUuNSIgZD0ibTAtMjkuMTQxLTI1LjIzNjksNDMuNzExNSA1MC40NzM4LTB6Ii8+DQo8L2RlZnM+DQo8cGF0aCBmaWxsPSIjZmZmIiBkPSJtMCwwaDIyMHYxNjBoLTIyMHoiLz4NCjxnIGZpbGw9IiMwMDM4YjgiPg0KPHBhdGggZD0ibTAsMTVoMjIwdjI1aC0yMjB6Ii8+DQo8cGF0aCBkPSJtMCwxMjBoMjIwdjI1aC0yMjB6Ii8+DQo8L2c+DQo8dXNlIHhsaW5rOmhyZWY9IiN0cmlhbmdsZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTEwIDgwKSIvPg0KPHVzZSB4bGluazpocmVmPSIjdHJpYW5nbGUiIHRyYW5zZm9ybT0ibWF0cml4KC0xIDAgLTAgLTEgMTEwIDgwKSIvPg0KPC9zdmc+DQo="> 53 </a> 54 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_sa.md"> 55 <img height="20px" src="https://img.shields.io/badge/SA-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBoZWlnaHQ9IjYwMCIgdmlld0JveD0iMCAwIDEyIDYiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4NCjxwYXRoIGZpbGw9IiNjZTExMjYiIGQ9Im0wLDBoM3Y2aC0zeiIvPg0KPHBhdGggZmlsbD0iIzAwOWEwMCIgZD0ibTMsMGg5djJoLTl6Ii8+DQo8cGF0aCBmaWxsPSIjZmZmIiBkPSJtMywyaDl2MmgtOXoiLz4NCjxwYXRoIGQ9Im0zLDRoOXYyaC05eiIvPg0KPC9zdmc+DQo="> 56 </a> 57 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_fa.md"> 58 <img height="20px" src="https://img.shields.io/badge/IR-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwMCIgaGVpZ2h0PSI1NzIuMiIgdmlld0JveD0iLTcuMjE3IC00LjEyOSAxMDAwIDU3Mi4yIj48cGF0aCBkPSJNLTcuMjE3LTQuMTI5aDEwMDB2NTcyLjJoLTEwMDB6IiBmaWxsPSIjMjM5ZjQwIi8+PHBhdGggZD0iTS03LjIxNyAyODEuOTcxaDEwMDB2Mjg2LjFoLTEwMDB6IiBmaWxsPSIjZGEwMDAwI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MjgxLjk3MSkiIGZpbGw9IiNkYTAwMDAiPjxnIGlkPSJmIj48cGF0aCBkPSJNLS41NDguODM2QS45MTIuOTEyIDAgMCAwIC4zMjktLjcyMiAxIDEgMCAwIDEtLjU0OC44MzYiLz48cGF0aCBkPSJNLjYxOC42NjFBLjc2NC43NjQgMCAwIDAgLjQyMi0uNzQgMSAxIDAgMCAxIC42MTguNjYxTTAgMWwtLjA1LTFMMC0uNzg3YS4zMS4zMSAwIDAgMCAuMTE4LjA5OVYtLjFsLS4wNC45OTN6TS0uMDItLjg1TDAtLjgzMWEuMTQ0LjE0NCAwIDAgMCAuMjUyLS4xMzdBLjEzNi4xMzYgMCAwIDEgMC0uOTI1Ii8+PC9nPjx1c2UgeGxpbms6aHJlZj0iI2YiIHRyYW5zZm9ybT0ic2NhbGUoLTEgMSkiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiLz48L2c+PC9zdmc+"> 59 </a> 60 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_it.md"> 61 <img height="20px" src="https://img.shields.io/badge/IT-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTUwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBoZWlnaHQ9IjEwMDAiIHZpZXdCb3g9IjAgMCAzIDIiPg0KPHBhdGggZmlsbD0iIzAwOTI0NiIgZD0ibTAsMGgxdjJoLTF6Ii8+DQo8cGF0aCBmaWxsPSIjZmZmIiBkPSJtMSwwaDF2MmgtMXoiLz4NCjxwYXRoIGZpbGw9IiNjZTJiMzciIGQ9Im0yLDBoMXYyaC0xeiIvPg0KPC9zdmc+DQo="> 62 </a> 63 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_ckb.md"> 64 <img height="20px" src="https://img.shields.io/badge/CKB-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwM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8+PC9zdmc+"> 65 </a> 66 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_uk.md"> 67 <img height="20px" src="https://img.shields.io/badge/UK-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU1LjIgMzguNCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTUuMiAzOC40IiB4bWw6c3BhY2U9InByZXNlcnZlIj48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWwoJLnN0MHtmaWxsOiNGRkQ1MDA7fQoJLnN0MXtmaWxsOiMwMDVCQkI7fQpdXT48L3N0eWxlPjxnPjxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik0zLjAzLDBoNDkuMTNjMS42NywwLDMuMDMsMS4zNiwzLjAzLDMuMDN2MzIuMzNjMCwxLjY3LTEuMzcsMy4wMy0zLjAzLDMuMDNIMy4wM0MxLjM3LDM4LjQsMCwzNy4wNCwwLDM1LjM3IFYzLjAzQzAsMS4zNiwxLjM3LDAsMy4wMywwTDMuMDMsMHoiLz48cGF0aCBjbGFzcz0ic3QwIiBkPSJNMCwxOS4yaDU1LjJ2MTYuMTdjMCwxLjY3LTEuMzcsMy4wMy0zLjAzLDMuMDNIMy4wM0MxLjM3LDM4LjQsMCwzNy4wNCwwLDM1LjM3VjE5LjJMMCwxOS4yeiIvPjwvZz48L3N2Zz4="> 68 </a> 69 <a href="https://github.com/gofiber/fiber/blob/master/.github/README_az.md"> 70 <img height="20px" src="https://img.shields.io/badge/AZ-flag.svg?color=555555&style=flat-square&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTIwMCIgaGVpZ2h0PSI2MDAiPg0KPHJlY3Qgd2lkdGg9IjEyMDAiIGhlaWdodD0iNjAwIiBmaWxsPSIjNTA5ZTJmIi8+DQo8cmVjdCB3aWR0aD0iMTIwMCIgaGVpZ2h0PSI0MDAiIGZpbGw9IiNlZjMzNDAiLz4NCjxyZWN0IHdpZHRoPSIxMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iIzAwYjVlMiIvPg0KPGNpcmNsZSBjeD0iNTcwIiBjeT0iMzAwIiByPSI5MCIgZmlsbD0iI2ZmZiIvPg0KPGNpcmNsZSBjeD0iNTkwIiBjeT0iMzAwIiByPSI3NSIgZmlsbD0iI2VmMzM0MCIvPg0KPHBhdGggZD0iTTY3MCAyNTBsOS41NjcgMjYuOTAzIDI1Ljc4OC0xMi4yNTgtMTIuMjU4IDI1Ljc4OEw3MjAgMzAwbC0yNi45MDMgOS41NjcgMTIuMjU4IDI1Ljc4OC0yNS43ODgtMTIuMjU4TDY3MCAzNTBsLTkuNTY3LTI2LjkwMy0yNS43ODggMTIuMjU4IDEyLjI1OC0yNS43ODhMNjIwIDMwMGwyNi45MDMtOS41NjctMTIuMjU4LTI1Ljc4OCAyNS43ODggMTIuMjU4eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+"> 71 </a> 72 <br> 73 <a href="https://pkg.go.dev/github.com/gofiber/fiber/v2#pkg-overview"> 74 <img src="https://img.shields.io/badge/%F0%9F%93%9A%20godoc-pkg-00ACD7.svg?color=00ACD7&style=flat-square"> 75 </a> 76 <a href="https://goreportcard.com/report/github.com/gofiber/fiber/v2"> 77 <img src="https://img.shields.io/badge/%F0%9F%93%9D%20goreport-A%2B-75C46B?style=flat-square"> 78 </a> 79 <a href="https://gocover.io/github.com/gofiber/fiber"> 80 <img src="https://img.shields.io/badge/%F0%9F%94%8E%20gocover-97.8%25-75C46B.svg?style=flat-square"> 81 </a> 82 <a href="https://github.com/gofiber/fiber/actions?query=workflow%3ASecurity"> 83 <img src="https://img.shields.io/github/actions/workflow/status/gofiber/fiber/security.yml?branch=master&label=%F0%9F%94%91%20gosec&style=flat-square&color=75C46B"> 84 </a> 85 <a href="https://github.com/gofiber/fiber/actions?query=workflow%3ATest"> 86 <img src="https://img.shields.io/github/actions/workflow/status/gofiber/fiber/test.yml?branch=master&label=%F0%9F%A7%AA%20tests&style=flat-square&color=75C46B"> 87 </a> 88 <a href="https://docs.gofiber.io"> 89 <img src="https://img.shields.io/badge/%F0%9F%92%A1%20fiber-docs-00ACD7.svg?style=flat-square"> 90 </a> 91 <a href="https://gofiber.io/discord"> 92 <img src="https://img.shields.io/discord/704680098577514527?style=flat-square&label=%F0%9F%92%AC%20discord&color=00ACD7"> 93 </a> 94 95 </p> 96 <p align="center"> 97 <b>Fiber</b> 是款啟發自 <a href="https://github.com/expressjs/express">Express</a> 的 <b>Web 框架</b>,建基於 <a href="https://github.com/valyala/fasthttp">Fasthttp</a>——<a href="https://go.dev/doc/">Go</a> 上<b>最快的</b> HTTP 引擎。設計旨在 <b>減輕</b> 快速開發的負擔,兼顧 <b>零記憶體分配</b> 和 <b>效能</b>。 98 </p> 99 100 ## ⚡️ 快速入門 101 102 ```go 103 package main 104 105 import "github.com/boomhut/fiber/v2" 106 107 func main() { 108 app := fiber.New() 109 110 app.Get("/", func(c *fiber.Ctx) error { 111 return c.SendString("Hello, World 👋!") 112 }) 113 114 app.Listen(":3000") 115 } 116 ``` 117 118 ## 🤖 效能評定結果 119 120 這些測試由 [TechEmpower](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=plaintext) 和 [Go Web 框架效能測試](https://github.com/smallnest/go-web-framework-benchmark) 完成。若需參閱所有結果,請參閱我們的 [Wiki](https://docs.gofiber.io/extra/benchmarks) 資訊。 121 122 <p float="left" align="middle"> 123 <img src="https://raw.githubusercontent.com/gofiber/docs/master/static/img/benchmark-pipeline.png" width="49%"> 124 <img src="https://raw.githubusercontent.com/gofiber/docs/master/static/img/benchmark_alloc.png" width="49%"> 125 </p> 126 127 ## ⚙️ 安裝 128 129 先確定您已經安裝 `1.17` 或更新版本的 Go([點此下載](https://go.dev/dl/))。 130 131 要初始化專案,首先建立檔案夾,然後在檔案夾中執行 `go mod init github.com/名稱/儲存庫`([深入了解](https://go.dev/blog/using-go-modules))。接著,使用 [`go get`](https://pkg.go.dev/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) 命令安裝 Fiber: 132 133 ```bash 134 go get -u github.com/gofiber/fiber/v2 135 ``` 136 137 ## 🎯 特色 138 139 - 強固的[路由系統](https://docs.gofiber.io/guide/routing) 140 - 可以寄存[靜態檔案](https://docs.gofiber.io/api/app#static) 141 - 疾速[效能](https://docs.gofiber.io/extra/benchmarks) 142 - 相當低的[記憶體使用量](https://docs.gofiber.io/extra/benchmarks) 143 - [API 端點](https://docs.gofiber.io/api/ctx) 144 - 支援 [中介模組](https://docs.gofiber.io/category/-middleware) 和 [接續函式 (Next)](https://docs.gofiber.io/api/ctx#next) 145 - [迅速開發](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) 伺服器端服務 146 - 強大的[路由](https://docs.gofiber.io/guide/routing) 147 - [靜態檔案](https://docs.gofiber.io/api/app#static)服務 148 - [超快速](https://docs.gofiber.io/extra/benchmarks) 149 - [佔用很少記憶體](https://docs.gofiber.io/extra/benchmarks) 150 - 支援 Express 的[API](https://docs.gofiber.io/api/ctx) 151 - 支援中介器和[下一步](https://docs.gofiber.io/api/ctx#next) 152 - [立即上手](https://dev.to/koddr/welcome-to-fiber-an-express-js-styled-fastest-web-framework-written-with-on-golang-497) 153 - [樣板引擎](https://github.com/gofiber/template) 154 - [支援 WebSocket](https://github.com/gofiber/websocket) 155 - [Server-Sent Events](https://github.com/gofiber/recipes/tree/master/sse) 156 - 支援[速率限制](https://docs.gofiber.io/api/middleware/limiter) 157 - 有 [18 門語言](https://docs.gofiber.io/)的翻譯 158 - 還有很多功能,[開始探索 Fiber](https://docs.gofiber.io/) 159 160 ## 💡 設計哲學 161 162 從 [Node.js](https://nodejs.org/en/about/) 轉到 [Go](https://go.dev/doc/) 的新進 Go 開發者,得先面對 Go 的各種知識點,才能開始建構自己的 Web 應用程式或微服務。Fiber 作為一款 **Web 框架**,設計之初便以 **極簡主義** 為理念,並遵循 **UNIX 之道**,讓新進 Go 開發者能夠快速隨著友善且值得信賴的社群,進入 Go 的世界。 163 164 Fiber **啟發自** Express——網際網路上最知名的 Web 框架,我們將 Express 的 **易用性** 和 Go 的 **原始效能** 結合在一起。如果您曾經在 Node.js(使用 Express 或類似框架)實作過 Web 應用程式,那麼許多方法和開發準則,將讓您感到 **無比熟悉**。 165 166 我們 **傾聽** 使用者在 [Issues](https://github.com/gofiber/fiber/issues)、Discord [群組](https://gofiber.io/discord) 和 **網路上任何角落** 的意見和建議,製作出 **快速**、**靈活** 且 **易於上手** 的 Go Web 框架,來應對**任何**工作、**繳件期限**以及開發者的**能力區間**——如同 Express 在 JavaScript 世界所扮演的角色一樣! 167 168 ## ⚠️ 限制 169 170 - 由於 Fiber 有用到 Unsafe,本函式庫有時可能無法相容最新版的 Go 語言。Fiber 2.40.0 已在 Go 1.17 至 1.20 的版本測試過。 171 - Fiber 不相容 net/http 的介面,意味著您無法使用像是 gqlgen、go-swagger 或其他任何屬於 net/http 生態系統的專案。 172 173 ## 👀 範例 174 175 下方列出一些常見範例。如果您想查看更多程式碼範例,請參閱我們的 [Recipes 儲存庫](https://github.com/gofiber/recipes),或前往我們提供的 [API 文件](https://docs.gofiber.io)。 176 177 #### 📖 [**基礎路由**](https://docs.gofiber.io/#basic-routing) 178 179 ```go 180 func main() { 181 app := fiber.New() 182 183 // GET /api/register 184 app.Get("/api/*", func(c *fiber.Ctx) error { 185 msg := fmt.Sprintf("✋ %s", c.Params("*")) 186 return c.SendString(msg) // => ✋ register 187 }) 188 189 // GET /flights/LAX-SFO 190 app.Get("/flights/:from-:to", func(c *fiber.Ctx) error { 191 msg := fmt.Sprintf("💸 從:%s,到:%s", c.Params("from"), c.Params("to")) 192 return c.SendString(msg) // => 💸 從:LAX,到:SFO 193 }) 194 195 // GET /dictionary.txt 196 app.Get("/:file.:ext", func(c *fiber.Ctx) error { 197 msg := fmt.Sprintf("📃 %s.%s", c.Params("file"), c.Params("ext")) 198 return c.SendString(msg) // => 📃 dictionary.txt 199 }) 200 201 // GET /john/75 202 app.Get("/:name/:age/:gender?", func(c *fiber.Ctx) error { 203 msg := fmt.Sprintf("👴 %s 已經 %s 歲了", c.Params("name"), c.Params("age")) 204 return c.SendString(msg) // => 👴 john 已經 75 歲了 205 }) 206 207 // GET /john 208 app.Get("/:name", func(c *fiber.Ctx) error { 209 msg := fmt.Sprintf("哈囉,%s 👋!", c.Params("name")) 210 return c.SendString(msg) // => 哈囉,john 👋! 211 }) 212 213 log.Fatal(app.Listen(":3000")) 214 } 215 216 ``` 217 218 #### 📖 [**路由命名**](https://docs.gofiber.io/api/app#name) 219 220 ```go 221 func main() { 222 app := fiber.New() 223 224 // GET /api/register 225 app.Get("/api/*", func(c *fiber.Ctx) error { 226 msg := fmt.Sprintf("✋ %s", c.Params("*")) 227 return c.SendString(msg) // => ✋ register 228 }).Name("api") 229 230 data, _ := json.MarshalIndent(app.GetRoute("api"), "", " ") 231 fmt.Print(string(data)) 232 // 會輸出: 233 // { 234 // "method": "GET", 235 // "name": "api", 236 // "path": "/api/*", 237 // "params": [ 238 // "*1" 239 // ] 240 // } 241 242 243 log.Fatal(app.Listen(":3000")) 244 } 245 246 ``` 247 248 #### 📖 [**寄存靜態檔案**](https://docs.gofiber.io/api/app#static) 249 250 ```go 251 func main() { 252 app := fiber.New() 253 254 app.Static("/", "./public") 255 // => http://localhost:3000/js/script.js 256 // => http://localhost:3000/css/style.css 257 258 app.Static("/prefix", "./public") 259 // => http://localhost:3000/prefix/js/script.js 260 // => http://localhost:3000/prefix/css/style.css 261 262 app.Static("*", "./public/index.html") 263 // => http://localhost:3000/any/path/shows/index/html 264 265 log.Fatal(app.Listen(":3000")) 266 } 267 268 ``` 269 270 #### 📖 [**中介模組和接續函式 (Next)**](https://docs.gofiber.io/api/ctx#next) 271 272 ```go 273 func main() { 274 app := fiber.New() 275 276 // 符合任何路由 277 app.Use(func(c *fiber.Ctx) error { 278 fmt.Println("🥇 第一個處理常式") 279 return c.Next() 280 }) 281 282 // 符合所有 /api 開頭的路由 283 app.Use("/api", func(c *fiber.Ctx) error { 284 fmt.Println("🥈 第二個處理常式") 285 return c.Next() 286 }) 287 288 // GET /api/list 289 app.Get("/api/list", func(c *fiber.Ctx) error { 290 fmt.Println("🥉 最後一個處理常式") 291 return c.SendString("Hello, World 👋!") 292 }) 293 294 log.Fatal(app.Listen(":3000")) 295 } 296 297 ``` 298 299 <details> 300 <summary>📚 展示更多程式碼範例</summary> 301 302 ### 檢視引擎 303 304 📖 [組態設定](https://docs.gofiber.io/api/fiber#config) 305 📖 [引擎](https://github.com/gofiber/template) 306 📖 [轉譯 (render)](https://docs.gofiber.io/api/ctx#render) 307 308 若未指定檢視引擎,Fiber 預設採用 [html/template](https://pkg.go.dev/html/template/)。 309 310 如果您想執行部分檢視 (partials),或者是使用如 [amber](https://github.com/eknkc/amber)、[handlebars](https://github.com/aymerick/raymond)、[mustache](https://github.com/cbroglie/mustache) 或 [pug](https://github.com/Joker/jade) 等等不同的引擎…… 311 312 請參考我們的 [Template](https://github.com/gofiber/template) 套件——它支援多種檢視引擎。 313 314 ```go 315 package main 316 317 import ( 318 "github.com/boomhut/fiber/v2" 319 "github.com/gofiber/template/pug" 320 ) 321 322 func main() { 323 // 您可以在 app 初始化前設定檢視 (Views) 引擎: 324 app := fiber.New(fiber.Config{ 325 Views: pug.New("./views", ".pug"), 326 }) 327 328 // 現在,您可以用下面這種方式呼叫 `./views/home.pug` 樣板: 329 app.Get("/", func(c *fiber.Ctx) error { 330 return c.Render("home", fiber.Map{ 331 "title": "Homepage", 332 "year": 1999, 333 }) 334 }) 335 336 log.Fatal(app.Listen(":3000")) 337 } 338 ``` 339 340 ### 組合路由鏈 341 342 📖 [分組](https://docs.gofiber.io/api/app#group) 343 344 ```go 345 func middleware(c *fiber.Ctx) error { 346 fmt.Println("不要理我!") 347 return c.Next() 348 } 349 350 func handler(c *fiber.Ctx) error { 351 return c.SendString(c.Path()) 352 } 353 354 func main() { 355 app := fiber.New() 356 357 // 根 API 路由 358 api := app.Group("/api", middleware) // /api 359 360 // API v1 路由 361 v1 := api.Group("/v1", middleware) // /api/v1 362 v1.Get("/list", handler) // /api/v1/list 363 v1.Get("/user", handler) // /api/v1/user 364 365 // API v2 路由 366 v2 := api.Group("/v2", middleware) // /api/v2 367 v2.Get("/list", handler) // /api/v2/list 368 v2.Get("/user", handler) // /api/v2/user 369 370 // ... 371 } 372 373 ``` 374 375 ### 中介模組記錄器 376 377 📖 [記錄器](https://docs.gofiber.io/api/middleware/logger) 378 379 ```go 380 package main 381 382 import ( 383 "log" 384 385 "github.com/boomhut/fiber/v2" 386 "github.com/gofiber/fiber/v2/middleware/logger" 387 ) 388 389 func main() { 390 app := fiber.New() 391 392 app.Use(logger.New()) 393 394 // ... 395 396 log.Fatal(app.Listen(":3000")) 397 } 398 ``` 399 400 ### 跨原始來源資源共用 (CORS) 401 402 📖 [CORS](https://docs.gofiber.io/api/middleware/cors) 403 404 ```go 405 import ( 406 "log" 407 408 "github.com/boomhut/fiber/v2" 409 "github.com/gofiber/fiber/v2/middleware/cors" 410 ) 411 412 func main() { 413 app := fiber.New() 414 415 app.Use(cors.New()) 416 417 // ... 418 419 log.Fatal(app.Listen(":3000")) 420 } 421 ``` 422 423 在 `Origin` 標頭傳入任何網域來檢查 CORS 的效果: 424 425 ```bash 426 curl -H "Origin: http://example.com" --verbose http://localhost:3000 427 ``` 428 429 ### 自訂 404 回應 430 431 📖 [HTTP 方法](https://docs.gofiber.io/api/ctx#status) 432 433 ```go 434 func main() { 435 app := fiber.New() 436 437 app.Static("/", "./public") 438 439 app.Get("/demo", func(c *fiber.Ctx) error { 440 return c.SendString("This is a demo!") 441 }) 442 443 app.Post("/register", func(c *fiber.Ctx) error { 444 return c.SendString("Welcome!") 445 }) 446 447 // 最後一個中介模組,符合所有條件 448 app.Use(func(c *fiber.Ctx) error { 449 return c.SendStatus(404) 450 // => 404 "Not Found" 451 }) 452 453 log.Fatal(app.Listen(":3000")) 454 } 455 ``` 456 457 ### JSON 回應 458 459 📖 [JSON](https://docs.gofiber.io/api/ctx#json) 460 461 ```go 462 type User struct { 463 Name string `json:"name"` 464 Age int `json:"age"` 465 } 466 467 func main() { 468 app := fiber.New() 469 470 app.Get("/user", func(c *fiber.Ctx) error { 471 return c.JSON(&User{"John", 20}) 472 // => {"name":"John", "age":20} 473 }) 474 475 app.Get("/json", func(c *fiber.Ctx) error { 476 return c.JSON(fiber.Map{ 477 "success": true, 478 "message": "Hi John!", 479 }) 480 // => {"success":true, "message":"Hi John!"} 481 }) 482 483 log.Fatal(app.Listen(":3000")) 484 } 485 ``` 486 487 ### WebSocket 升級 (Upgrade) 488 489 📖 [Websocket](https://github.com/gofiber/websocket) 490 491 ```go 492 import ( 493 "github.com/boomhut/fiber/v2" 494 "github.com/gofiber/fiber/v2/middleware/websocket" 495 ) 496 497 func main() { 498 app := fiber.New() 499 500 app.Get("/ws", websocket.New(func(c *websocket.Conn) { 501 for { 502 mt, msg, err := c.ReadMessage() 503 if err != nil { 504 log.Println("read:", err) 505 break 506 } 507 log.Printf("recv: %s", msg) 508 err = c.WriteMessage(mt, msg) 509 if err != nil { 510 log.Println("write:", err) 511 break 512 } 513 } 514 })) 515 516 log.Fatal(app.Listen(":3000")) 517 // ws://localhost:3000/ws 518 } 519 ``` 520 521 ### Server-Sent Events 522 523 📖 [更多資訊](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) 524 525 ```go 526 import ( 527 "github.com/boomhut/fiber/v2" 528 "github.com/valyala/fasthttp" 529 ) 530 531 func main() { 532 app := fiber.New() 533 534 app.Get("/sse", func(c *fiber.Ctx) error { 535 c.Set("Content-Type", "text/event-stream") 536 c.Set("Cache-Control", "no-cache") 537 c.Set("Connection", "keep-alive") 538 c.Set("Transfer-Encoding", "chunked") 539 540 c.Context().SetBodyStreamWriter(fasthttp.StreamWriter(func(w *bufio.Writer) { 541 fmt.Println("WRITER") 542 var i int 543 544 for { 545 i++ 546 msg := fmt.Sprintf("%d - 目前時間為 %v", i, time.Now()) 547 fmt.Fprintf(w, "data: 訊息: %s\n\n", msg) 548 fmt.Println(msg) 549 550 w.Flush() 551 time.Sleep(5 * time.Second) 552 } 553 })) 554 555 return nil 556 }) 557 558 log.Fatal(app.Listen(":3000")) 559 } 560 ``` 561 562 ### Recover 中介模組 563 564 📖 [Recover](https://docs.gofiber.io/api/middleware/recover) 565 566 ```go 567 import ( 568 "github.com/boomhut/fiber/v2" 569 "github.com/gofiber/fiber/v2/middleware/recover" 570 ) 571 572 func main() { 573 app := fiber.New() 574 575 app.Use(recover.New()) 576 577 app.Get("/", func(c *fiber.Ctx) error { 578 panic("正常來說,這會導致 app 當機") 579 }) 580 581 log.Fatal(app.Listen(":3000")) 582 } 583 ``` 584 585 </details> 586 587 ### 使用信任的代理伺服器 588 589 📖 [組態設定](https://docs.gofiber.io/api/fiber#config) 590 591 ```go 592 import ( 593 "github.com/boomhut/fiber/v2" 594 "github.com/gofiber/fiber/v2/middleware/recover" 595 ) 596 597 func main() { 598 app := fiber.New(fiber.Config{ 599 EnableTrustedProxyCheck: true, 600 TrustedProxies: []string{"0.0.0.0", "1.1.1.1/30"}, // IP 地址或 IP 地址區間 601 ProxyHeader: fiber.HeaderXForwardedFor, 602 }) 603 604 // ... 605 606 log.Fatal(app.Listen(":3000")) 607 } 608 ``` 609 610 </details> 611 612 ## 🧬 內建中介模組 613 614 這裡列出了 Fiber 框架內建的中介模組。 615 616 | 中介模組 | 描述 | 617 | :------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 618 | [basicauth](https://github.com/gofiber/fiber/tree/master/middleware/basicauth) | 提供 HTTP Basic 認證的基本認證中介模組。如果憑證有效,則會呼叫接續函式 (next);如果沒有憑證或失效,則回傳 401 Unauthorized。 | 619 | [cache](https://github.com/gofiber/fiber/tree/master/middleware/cache) | 攔截並快取回應。 | 620 | [compress](https://github.com/gofiber/fiber/tree/master/middleware/compress) | 適用於 Fiber 的壓縮中介模組。預設支援 `deflate`、`gzip` 和 `brotli`。 | 621 | [cors](https://github.com/gofiber/fiber/tree/master/middleware/cors) | 啟用跨來源資源共用 (CORS),可調整多種選項。 | 622 | [csrf](https://github.com/gofiber/fiber/tree/master/middleware/csrf) | 保護資源防止 CSRF 利用。 | 623 | [encryptcookie](https://github.com/gofiber/fiber/tree/master/middleware/encryptcookie) | 加密中介模組,會將 Cookie 的值進行加密。 | 624 | [envvar](https://github.com/gofiber/fiber/tree/master/middleware/envvar) | 公開環境變數,並提供可調整設定。 | 625 | [etag](https://github.com/gofiber/fiber/tree/master/middleware/etag) | ETag 中介模組,讓快取更高效,同時因為 Web 伺服器不需要在內容未更動時重新傳送完整請求,因此可以減少流量使用。 | 626 | [expvar](https://github.com/gofiber/fiber/tree/master/middleware/expvar) | Expvar 中介模組,透過其 HTTP 伺服器執行階段,提供 JSON 格式的公用變數。 | 627 | [favicon](https://github.com/gofiber/fiber/tree/master/middleware/favicon) | 不輸出 Favicons 請求記錄;若有提供檔案路徑,則從記憶體提供圖示。 | 628 | [filesystem](https://github.com/gofiber/fiber/tree/master/middleware/filesystem) | 適用於 Fiber 的檔案系統中介模組。特別銘謝 Alireza Salary! | 629 | [limiter](https://github.com/gofiber/fiber/tree/master/middleware/limiter) | 適用於 Fiber 的速率限制中介模組。用來限制傳入公開 API 或者(以及)端點(如密碼重設)的重複請求。 | 630 | [logger](https://github.com/gofiber/fiber/tree/master/middleware/logger) | HTTP 請求/回應記錄工具。 | 631 | [monitor](https://github.com/gofiber/fiber/tree/master/middleware/monitor) | 監控中介模組,用來回報伺服器指標。啟發自 express-status-monitor。 | 632 | [pprof](https://github.com/gofiber/fiber/tree/master/middleware/pprof) | 特別感謝 Matthew Lee \(@mthli\) | 633 | [proxy](https://github.com/gofiber/fiber/tree/master/middleware/proxy) | 讓您可以將請求代理 (proxy) 至多台伺服器。 | 634 | [recover](https://github.com/gofiber/fiber/tree/master/middleware/recover) | Recover 中介模組:可以從呼叫堆疊鏈中任何部分的當機 (panic) 中復原,並將控制權交由中央的 [錯誤處理常式 (ErrorHandler)](https://docs.gofiber.io/guide/error-handling) 處理。 | 635 | [requestid](https://github.com/gofiber/fiber/tree/master/middleware/requestid) | 為每個請求加上 requestid。 | 636 | [session](https://github.com/gofiber/fiber/tree/master/middleware/session) | 連線階段中介模組。注意:這個中介模組有用到我們的 Storage 套件。 | 637 | [skip](https://github.com/gofiber/fiber/tree/master/middleware/skip) | 略過中介模組,會在條件成立時略過封裝過的處理常式。 | 638 | [timeout](https://github.com/gofiber/fiber/tree/master/middleware/timeout) | 為請求加上最長時限,並在逾時後轉送至錯誤處理常式 (ErrorHandler)。 | 639 | [keyauth](https://github.com/gofiber/keyauth) | Key auth 中介模組提供以金鑰為基礎的認證模式。 | 640 | [redirect](https://github.com/gofiber/redirect) | 用來重新導向的中介模組。 | 641 | [rewrite](https://github.com/gofiber/rewrite) | 重寫 (Rewrite) 中介模組:根據提供規則重寫 URL 路徑,適合用來向後相容,或者是製作更乾淨且更好懂的連結。 | 642 | [adaptor](https://github.com/gofiber/adaptor) | 將 net/http 處理常式轉換至 Fiber 處理常式,或者是反著做。特別感謝 @arsmn! | 643 | [helmet](https://github.com/gofiber/helmet) | 透過設定多種 HTTP 標頭,協助保護您應用程式的安全。 | 644 645 ## 🧬 外掛中介模組 646 647 這裡列出由 [Fiber 團隊](https://github.com/orgs/gofiber/people) 維護、存放在外部的中介模組。 648 649 | 中介模組 | 描述 | 650 | :------------------------------------------------ | :----------------------------------------------------------------------------------------------------- | 651 | [jwt](https://github.com/gofiber/jwt) | JWT 回傳 JSON Web Token \(JWT\) 認證中介模組。 | 652 | [storage](https://github.com/gofiber/storage) | 已經做好,實作 Storage 介面的儲存區驅動模組,設計用來與各種 Fiber 中介模組搭配使用。 | 653 | [template](https://github.com/gofiber/template) | 本套件包含 8 種樣板引擎,可以和 Fiber `v1.10.x` 一起使用。需要 Go 1.13 或更新版本。 | 654 | [websocket](https://github.com/gofiber/websocket) | 適用於 Fiber,建基於 Fasthttp 的 WebSocket。支援本機空間 (Locals)! | 655 656 ## 🕶️ Awesome List 657 658 更多文章、中介模組、範例或工具,請參考我們的 [Awesome List](https://github.com/gofiber/awesome-fiber)。 659 660 ## 👍 貢獻 661 662 如果您想和我們 **道謝**,或者是支持 `Fiber` 繼續積極開發下去(也可以兩個都做): 663 664 1. 送給專案一顆 [GitHub 星星](https://github.com/gofiber/fiber/stargazers)。 665 2. [在您的 Twitter 上](https://twitter.com/intent/tweet?text=Fiber%20is%20an%20Express%20inspired%20%23web%20%23framework%20built%20on%20top%20of%20Fasthttp%2C%20the%20fastest%20HTTP%20engine%20for%20%23Go.%20Designed%20to%20ease%20things%20up%20for%20%23fast%20development%20with%20zero%20memory%20allocation%20and%20%23performance%20in%20mind%20%F0%9F%9A%80%20https%3A%2F%2Fgithub.com%2Fgofiber%2Ffiber)發出關於本專案的推文。 666 3. 在 [Medium](https://medium.com/)、[Dev.to](https://dev.to/) 或者是個人部落格上寫下評論或教學。 667 4. 捐專案 [一杯咖啡的費用](https://buymeacoff.ee/fenny) 以示支持。 668 669 ## ☕ 支持者 670 671 Fiber 是個仰賴捐款的開放原始碼專案——用來支付如域名、Gitbook、Netlify 和無服務器運算服務的費用。如果您想支持 Fiber,可以在 ☕ [**這裡捐杯咖啡**](https://buymeacoff.ee/fenny)。 672 673 | | 使用者 | 捐款 | 674 | :--------------------------------------------------------- | :----------------------------------------------- | :------ | 675 |  | [@destari](https://github.com/destari) | ☕ x 10 | 676 |  | [@dembygenesis](https://github.com/dembygenesis) | ☕ x 5 | 677 |  | [@thomasvvugt](https://github.com/thomasvvugt) | ☕ x 5 | 678 |  | [@hendratommy](https://github.com/hendratommy) | ☕ x 5 | 679 |  | [@ekaputra07](https://github.com/ekaputra07) | ☕ x 5 | 680 |  | [@jorgefuertes](https://github.com/jorgefuertes) | ☕ x 5 | 681 |  | [@candidosales](https://github.com/candidosales) | ☕ x 5 | 682 |  | [@l0nax](https://github.com/l0nax) | ☕ x 3 | 683 |  | [@bihe](https://github.com/bihe) | ☕ x 3 | 684 |  | [@justdave](https://github.com/justdave) | ☕ x 3 | 685 |  | [@koddr](https://github.com/koddr) | ☕ x 1 | 686 |  | [@lapolinar](https://github.com/lapolinar) | ☕ x 1 | 687 |  | [@diegowifi](https://github.com/diegowifi) | ☕ x 1 | 688 |  | [@ssimk0](https://github.com/ssimk0) | ☕ x 1 | 689 |  | [@raymayemir](https://github.com/raymayemir) | ☕ x 1 | 690 |  | [@melkorm](https://github.com/melkorm) | ☕ x 1 | 691 |  | [@marvinjwendt](https://github.com/marvinjwendt) | ☕ x 1 | 692 |  | [@toishy](https://github.com/toishy) | ☕ x 1 | 693 694 ## 💻 程式碼貢獻者 695 696 <img src="https://opencollective.com/fiber/contributors.svg?width=890&button=false" alt="Code Contributors" style="max-width:100%;"> 697 698 ## ⭐️ 收藏數 699 700 <img src="https://starchart.cc/gofiber/fiber.svg" alt="Stargazers over time" style="max-width: 100%"> 701 702 ## ⚠️ 授權條款 703 704 著作權所有 (c) 2019-現在 [Fenny](https://github.com/fenny) 和[貢獻者](https://github.com/gofiber/fiber/graphs/contributors)。`Fiber` 是款依照 [MIT License](https://github.com/gofiber/fiber/blob/master/LICENSE) 授權,免費且開放原始碼的軟體。官方圖示 (logo) 由 [Vic Shóstak](https://github.com/koddr) 製作,並依據 [創用 CC](https://creativecommons.org/licenses/by-sa/4.0/) 授權條款散佈 (CC BY-SA 4.0 International)。 705 706 **第三方函式庫的授權條款** 707 708 - [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE) 709 - [isatty](https://github.com/mattn/go-isatty/blob/master/LICENSE) 710 - [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE) 711 - [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE) 712 - [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE) 713 - [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE) 714 - [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md) 715 - [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE) 716 - [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE) 717 - [msgp](https://github.com/tinylib/msgp/blob/master/LICENSE) 718 - [schema](https://github.com/gorilla/schema/blob/master/LICENSE) 719 - [uuid](https://github.com/google/uuid/blob/master/LICENSE) 720 - [wmi](https://github.com/StackExchange/wmi/blob/master/LICENSE)