1"use strict";(self.webpackChunksmocker_docs=self.webpackChunksmocker_docs||[]).push([[149],{9095:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>p,frontMatter:()=>t,metadata:()=>c,toc:()=>d});var s=r(4848),i=r(8453);const t={sidebar_position:1},o="What is Smocker?",c={id:"guide/intro",title:"What is Smocker?",description:"Smocker (server mock) is a simple and efficient HTTP mock server.",source:"@site/docs/guide/intro.md",sourceDirName:"guide",slug:"/guide/intro",permalink:"/docs/guide/intro",draft:!1,unlisted:!1,editUrl:"https://github.com/smocker-dev/docs/tree/main/docs/guide/intro.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1},sidebar:"documentationSidebar",previous:{title:"Guide",permalink:"/docs/category/guide"},next:{title:"Installation",permalink:"/docs/guide/installation"}},a={},d=[];function l(e){const n={a:"a",code:"code",h1:"h1",img:"img",li:"li",mermaid:"mermaid",p:"p",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"what-is-smocker",children:"What is Smocker?"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Smocker"})," (server mock) is a simple and efficient HTTP mock server."]}),"\n",(0,s.jsxs)(n.p,{children:["The goal of Smocker is to help you ",(0,s.jsx)(n.strong,{children:"mock the HTTP dependencies of your application"}),". It's a great tool for ",(0,s.jsx)(n.strong,{children:"integration tests automation"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Smocker really shines in a ",(0,s.jsx)(n.strong,{children:"microservice environment with an API gateway"}
1),". On your development or test infrastructure, you just need to deploy it instead of your API gateway and have your application use it as the gateway."]}),"\n",(0,s.jsxs)("div",{class:"row wrap around-justified",children:[(0,s.jsxs)("div",{class:"text-center figure",children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Production environment, with an API gateway"})}),(0,s.jsx)(n.mermaid,{value:"graph LR\n App([Your Application])\n M1([Microservice 1])\n M2([Microservice 2])\n M3([Microservice 3])\n GW(API Gateway)\n E[External Service]\n\n App --\x3e E\n App --\x3e GW\n GW --\x3e M1\n GW --\x3e M2\n GW --\x3e M3"})]}),(0,s.jsxs)("div",{class:"text-center figure",children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Test environment, with Smocker"})}),(0,s.jsx)(n.mermaid,{value:'graph LR\n E[External Service]\n App([Your Application])\n M1([Mocked Microservice 1])\n M2([Mocked Microservice 2])\n M3([Microservice 3])\n S(Smocker)\n\n App --\x3e E\n App --\x3e S\n\n subgraph " "\n S --\x3e M1\n S --\x3e M2\n end\n\n S --forward request--\x3e M3\n\n style S stroke:#b51629,stroke-width:3px'})]})]}),"\n",(0,s.jsxs)(n.p,{children:["Smocker can also be used as an ",(0,s.jsx)(n.strong,{children:"HTTP proxy"})," through the commonly used ",(0,s.jsx)(n.code,{children:"http_proxy"})," environment variable."]}),"\n",(0,s.jsxs)("div",{class:"row wrap around-justified",children:[(0,s.jsxs)("div",{class:"text-center figure",children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Production environment"})}),(0,s.jsx)(n.mermaid,{value:"graph LR\n E[External Service]\n App([Your Application])\n M1([Microservice 1])\n M2([Microservice 2])\n M3([Microservice 3])\n\n App --\x3e E\n App --\x3e M1\n App --\x3e M2\n App --\x3e M3"})]}),(0,s.jsxs)("div",{class:"text-center figure",children:[(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["Test environment, with Smocker using ",(0,s.jsx)(n.code,{children:"http_proxy"})]})}),(0,s.jsx)(n.mermaid,{value:'graph LR\n App([Your Application])\n\n subgraph " "\n S(Smocker)\n M1([Mocked Microservice 1])\n M2([Mocked Microservice 2])\n S --\x3e M1\n S --\x3e M2\n end\n\n subgraph transparent-1\n M3([Microservice 3])\n S --forward request--\x3e M3\n end\n\n subgraph transparent-2\n E[External Service]\n S --forward request--\x3e E\n end\n\n App ==http_proxy==> S\n\n style S stroke:#b51629,stroke-width:3px'})]})]}),"\n",(0,s.jsx)(n.p,{children:"Smocker provides several powerful ways to setup your testing environment:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"/docs/technical-documentation/mock-definition#format-of-response-section",children:(0,s.jsx)(n.strong,{children:"Static mocks"})})," return a static response for a given request. It's the most basic behavior of Smocker,"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"/docs/technical-documentation/mock-definition#format-of-dynamic_response-section",children:(0,s.jsx)(n.strong,{children:"Dynamic mocks"})})," return a response with variable parts. Dynamic mocks can be declared using ",(0,s.jsx)(n.a,{href:"https://golang.org/pkg/html/template/",children:"Go templates"})," or ",(0,s.jsx)(n.a,{href:"https://www.lua.org/",children:"Lua"}),","]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"/docs/technical-documentation/mock-definition#format-of-proxy-section",children:(0,s.jsx)(n.strong,{children:"Proxies"})})," just forward the request to an actual server, because mocking is not always suitable for testing."]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Smocker also has a great ",(0,s.jsx)(n.strong,{children:"user interface"})," which we use extensively to write tests iteratively."]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Smocker's user interface - Mocks",src:r(6692).A+"",width:"1400",height:"700"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Smocker's user interface - History",src:r(3365).A+"",width:"1400",height:"700"})})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},3365:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/screenshot-history-aa1c8b9402e53d4d194c7a63d49a7a7a.png"},6692:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/screenshot-mocks-5e6a440e1ea4f2efc72557ba509c4e2c.png"}}]);
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.