PageSourceSearch

https://docs.gofiber.io/assets/js/f9aeed9d.23e45cce.js

js gofiber.io collected 2026-09-25 14:20:17 UTC 3,618 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkfiber_docs=self.webpackChunkfiber_docs||[]).push([["12839"],{16004(e,n,r){r.r(n),r.d(n,{metadata:()=>t,default:()=>p,frontMatter:()=>a,contentTitle:()=>d,toc:()=>l,assets:()=>c});var t=JSON.parse('{"id":"middleware/skip","title":"Skip","description":"The Skip middleware wraps a handler and bypasses it when the predicate returns true for the current request.","source":"@site/versioned_docs/version-v3.x/middleware/skip.md","sourceDirName":"middleware","slug":"/middleware/skip","permalink":"/middleware/skip","draft":false,"unlisted":false,"tags":[],"version":"v3.x","lastUpdatedAt":1790279268000,"frontMatter":{"id":"skip"},"sidebar":"left_sidebar","previous":{"title":"Session","permalink":"/middleware/session"},"next":{"title":"SSE","permalink":"/middleware/sse"}}'),i=r(474848),s=r(28453);let a={id:"skip"},d="Skip",c={},l=[{value:"Signatures",id:"signatures",level:2},{value:"Examples",id:"examples",level:2}];function o(e){let n={admonition:"admonition",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"skip",children:"Skip"})}),"\n",(0,i.jsxs)(n.p,{children:["The Skip middleware wraps a handler and bypasses it when the predicate returns ",(0,i.jsx)(n.code,{children:"true"})," for the current request."]}),"\n",(0,i.jsx)(n.h2,{id:"signatures",children:"Signatures"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func New(handler fiber.Handler, exclude func(c fiber.Ctx) bool) fiber.Handler\n"})}),"\n",(0,i.jsx)(n.h2,{id:"examples",children:"Examples"}),"\n",(0,i.jsx)(n.p,{children:"Import the package:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'import (\n    "github.com/gofiber/fiber/v3"\n    "github.com/gofiber/fiber/v3/middleware/skip"\n)\n'})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"skip.New"})," accepts the handler to wrap and a predicate function. The predicate\nruns for every request, and returning ",(0,i.jsx)(n.code,{children:"true"})," skips the wrapped handler and\nexecutes the next middleware in the chain."]}),"\n",(0,i.jsxs)(n.p,{children:["After you initialize your Fiber app, use ",(0,i.jsx)(n.code,{children:"skip.New"})," like this:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n    app := fiber.New()\n\n    app.Use(skip.New(BasicHandler, func(ctx fiber.Ctx) bool {\n        return ctx.Method() == fiber.MethodGet\n    }))\n\n    app.Get("/", func(ctx fiber.Ctx) error {\n        return ctx.SendString("It was a GET request!")\n    })\n\n    log.Fatal(app.Listen(":3000"))\n}\n\nfunc BasicHandler(ctx fiber.Ctx) error {\n    return ctx.SendString("It was not a GET request!")\n}\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"app.Use"})," processes requests on any route and method. In the example above, the handler is skipped only for ",(0,i.jsx)(n.code,{children:"GET"}),"."]})})]})}function p(e={}){let{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}},28453(e,n,r){r.d(n,{R:()=>a,x:()=>d});var t=r(296540);let i={},s=t.createContext(i);function a(e){let n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.