This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Get-ChildItem -Exclude "*.pdf" | rename-item -NewName { $_.Name + ".pdf" } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Cypress.Commands.add("visitWait", (url, options) => { | |
| cy.visit(url, options); | |
| cy.get('[data-test=loaded]'); | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <script> | |
| import Nav from '../components/Nav.svelte'; | |
| import { onMount, tick } from 'svelte'; | |
| export let segment; | |
| let testID = 'loading'; | |
| onMount(() => { | |
| tick().then(() => { | |
| testID = 'loaded'; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "strings" | |
| "github.com/benjohns1/go-middleware-example/apiexample/businessdomain" | |
| "github.com/benjohns1/go-middleware-example/apiexample/middleware" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package middleware | |
| import ( | |
| "log" | |
| "math/rand" | |
| "net/http" | |
| ) | |
| // RandAuthStrategy randomly authorizes a request (this is highly recommended for use in production to maximize user frustration and minimize revenue) | |
| func RandAuthStrategy() bool { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package middleware | |
| import ( | |
| "log" | |
| "net/http" | |
| ) | |
| type logResponseWriter struct { | |
| http.ResponseWriter | |
| status int | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package middleware | |
| import "net/http" | |
| // Factory generates an http handler func in a middleware chain | |
| type Factory func(next http.HandlerFunc) http.HandlerFunc | |
| // Chain generates an http handler recursively from a list of middleware factory functions | |
| func Chain(chain ...Factory) http.Handler { | |
| return http.HandlerFunc(recurseChain(chain)) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package businessdomain | |
| // ResponseData contains business logic response data | |
| type ResponseData struct { | |
| Data string | |
| } | |
| // BusinessLogic runs domain business logic | |
| func BusinessLogic() (resp *ResponseData, err error) { | |
| // ... do something ... | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "math/rand" | |
| "net/http" | |
| ) | |
| type middlewareFunc func(next http.HandlerFunc) http.HandlerFunc | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | type logResponseWriter struct { | |
| http.ResponseWriter | |
| status int | |
| extra string | |
| } | |
| func logger(next http.HandlerFunc) http.HandlerFunc { | |
| return func(w http.ResponseWriter, r *http.Request) { | |
| log.Printf("Request: %v", r.URL.Path) | |
| lw := &logResponseWriter{ResponseWriter: w} | 
NewerOlder