"use strict";(self.webpackChunkgoffee_site=self.webpackChunkgoffee_site||[]).push([[268],{5040:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>u,frontMatter:()=>s,metadata:()=>c,toc:()=>a});var o=n(4848),r=n(8453);const s={title:"Routing"},i=void 0,c={id:"routing",title:"Routing",description:"All routes are defined in the file routes.go which is located in the root dir, here is an example for defining a route:",source:"@site/docs/routing.md",sourceDirName:".",slug:"/routing",permalink:"/goffee/docs/routing",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"Routing"},sidebar:"docsSidebar",previous:{title:"Environment Variables",permalink:"/goffee/docs/environment-variables"},next:{title:"Controllers",permalink:"/goffee/docs/controllers"}},l={},a=[];function d(e){const t={a:"a",code:"code",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(t.p,{children:["All routes are defined in the file ",(0,o.jsx)(t.code,{children:"routes.go"})," which is located in the root dir, here is an example for defining a route:"]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-go",metastring:'title="#file: routes.go"',children:'package main\n\nimport (\n\t"git.smarteching.com/goffee/core"\n\t"git.smarteching.com/goffee/goffee/controllers"\n)\n\n// Register the app routes\nfunc registerRoutes() {\n\trouter := core.ResolveRouter()\n\t//#############################\n\t//# App Routes            #####\n\t//#############################\n\n\t// Define your routes here...\n    controller.Get("/todos", controllers.ListTodos)\n}\n'})}),"\n",(0,o.jsxs)(t.p,{children:["Where ",(0,o.jsx)(t.code,{children:"controllers.ListTodos"})," is the handler function that handles the request."]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-go",metastring:'title="#file: controllers/todos.go"',children:'package controllers\n\nimport (\n    "git.smarteching.com/goffee/core"\n)\n\nfunc ListTodos(c *core.Context) *core.Response {\n    //The logic for listing users\n}\n'})}),"\n",(0,o.jsxs)(t.p,{children:["to learn more about ",(0,o.jsx)(t.code,{children:"controllers"})," click ",(0,o.jsx)(t.a,{href:"/docs/controllers",children:"here"})]})]})}function u(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var o=n(6540);const r={},s=o.createContext(r);function i(e){const t=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),o.createElement(s.Provider,{value:t},e.children)}}}]);