(command.CommandList
  children: [
    (command.ShFunction
      name: 'balls::define_route'
      body: 
        (BraceGroup
          children: [
            (command.Sentence
              child: (C {<local>} {<Id.Lit_VarLike 'verb='> ($ Id.VSub_Number '$1')})
              terminator: <Id.Op_Semi _>
            )
            (C {<shift>})
            (command.Sentence
              child: (C {<local>} {<Id.Lit_VarLike 'path='> ($ Id.VSub_Number '$1')})
              terminator: <Id.Op_Semi _>
            )
            (C {<shift>})
            (command.Sentence
              child: (C {<local>} {<Id.Lit_VarLike 'action='> ($ Id.VSub_Number '$1')})
              terminator: <Id.Op_Semi _>
            )
            (C {<shift>})
            (C {<local>} 
              {<Id.Lit_VarLike 'route_line='> 
                (DQ 
                  (command_sub
                    left_token: <Id.Left_DollarParen '$('>
                    child: 
                      (C {<echo>} {<-e>} 
                        {
                          (DQ ($ Id.VSub_DollarName '$verb') <Id.Lit_BadBackslash '\\'> <t> 
                            ($ Id.VSub_DollarName '$path') <Id.Lit_BadBackslash '\\'> <t> ($ Id.VSub_DollarName '$action')
                          )
                        }
                      )
                  )
                )
              }
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$ROUTES'))} 
                              {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:ROUTES)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_DollarName '$route_line'))}
                          spids: [80]
                        )
                      ]
                    )
                  ]
                  spids: [64 77]
                )
              ]
              else_action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:ROUTES)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (DQ ($ Id.VSub_DollarName '$ROUTES') <'\n'> 
                            ($ Id.VSub_DollarName '$route_line')
                          )
                        }
                      spids: [89]
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: 'b:GET'
      body: 
        (BraceGroup
          children: [
            (command.Sentence
              child: 
                (C {<balls> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <define_route>} {<GET>} 
                  {(DQ ($ Id.VSub_At '$@'))}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
    )
    (command.ShFunction
      name: 'b:POST'
      body: 
        (BraceGroup
          children: [
            (command.Sentence
              child: 
                (C {<balls> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <define_route>} {<POST>} 
                  {(DQ ($ Id.VSub_At '$@'))}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
    )
    (command.ShFunction
      name: 'b:PUT'
      body: 
        (BraceGroup
          children: [
            (command.Sentence
              child: 
                (C {<balls> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <define_route>} {<PUT>} 
                  {(DQ ($ Id.VSub_At '$@'))}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
    )
    (command.ShFunction
      name: 'b:DELETE'
      body: 
        (BraceGroup
          children: [
            (command.Sentence
              child: 
                (C {<balls> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <define_route>} {<DELETE>} 
                  {(DQ ($ Id.VSub_At '$@'))}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
    )
    (command.ShFunction
      name: 'balls::route'
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_GlobEqual
                      left: {(DQ ($ Id.VSub_DollarName '$BALLS_RELOAD'))}
                      right: {<1>}
                    )
                )
                (C {<balls> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <load_app>})
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_GlobEqual
                      left: {(DQ ($ Id.VSub_DollarName '$REQUEST_METHOD'))}
                      right: {(DQ <HEAD>)}
                    )
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:body_sock)
                      op: assign_op.Equal
                      rhs: {<'/dev/null'>}
                      spids: [237]
                    )
                  ]
                )
              ]
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'action='> 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  child: 
                    (command.Pipeline
                      children: [
                        (C {<echo>} {(DQ ($ Id.VSub_DollarName '$ROUTES'))})
                        (C {<grep>} {(DQ <'^'> ($ Id.VSub_DollarName '$REQUEST_METHOD'))})
                        (BraceGroup
                          children: [
                            (command.WhileUntil
                              keyword: <Id.KW_While while>
                              cond: 
                                (condition.Shell
                                  commands: [
                                    (command.Sentence
                                      child: (C {<read>} {<line>})
                                      terminator: <Id.Op_Semi _>
                                    )
                                  ]
                                )
                              body: 
                                (command.DoGroup
                                  children: [
                                    (command.ShAssignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (sh_lhs_expr.Name name:arr)
                                          op: assign_op.Equal
                                          rhs: 
                                            {
                                              (sh_array_literal
                                                left: <Id.Op_LParen _>
                                                words: [{($ Id.VSub_DollarName '$line')}]
                                              )
                                            }
                                          spids: [278]
                                        )
                                      ]
                                    )
                                    (command.ShAssignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (sh_lhs_expr.Name name:path)
                                          op: assign_op.Equal
                                          rhs: 
                                            {
                                              (braced_var_sub
                                                token: <Id.VSub_Name arr>
                                                bracket_op: 
                                                  (bracket_op.ArrayIndex
                                                    expr: {<Id.Lit_Digits 1>}
                                                  )
                                              )
                                            }
                                          spids: [284]
                                        )
                                      ]
                                    )
                                    (command.ShAssignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (sh_lhs_expr.Name name:act)
                                          op: assign_op.Equal
                                          rhs: 
                                            {
                                              (braced_var_sub
                                                token: <Id.VSub_Name arr>
                                                bracket_op: 
                                                  (bracket_op.ArrayIndex
                                                    expr: {<Id.Lit_Digits 2>}
                                                  )
                                              )
                                            }
                                          spids: [293]
                                        )
                                      ]
                                    )
                                    (command.If
                                      arms: [
                                        (if_arm
                                          cond: 
                                            (condition.Shell
                                              commands: [
                                                (command.Sentence
                                                  child: 
                                                    (command.DBracket
                                                      expr: 
                                                        (bool_expr.Binary
                                                          op_id: Id.BoolBinary_GlobEqual
                                                          left: 
                                                            {
                                                              (DQ 
                                                                ($ Id.VSub_DollarName '$REQUEST_PATH')
                                                              )
                                                            }
                                                          right: {(DQ ($ Id.VSub_DollarName '$path'))}
                                                        )
                                                    )
                                                  terminator: <Id.Op_Semi _>
                                                )
                                              ]
                                            )
                                          action: [
                                            (C {<echo>} {($ Id.VSub_DollarName '$act')})
                                            (command.ControlFlow
                                              token: <Id.ControlFlow_Break break>
                                            )
                                          ]
                                          spids: [302 319]
                                        )
                                      ]
                                    )
                                  ]
                                )
                            )
                          ]
                        )
                      ]
                      negated: F
                    )
                )
              }
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.AndOr
                              ops: [Id.Op_DAmp]
                              children: [
                                (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ ($ Id.VSub_DollarName '$action'))} 
                                  {<Id.Lit_RBracket ']'>}
                                )
                                (C {<exists>} {(DQ ($ Id.VSub_DollarName '$action'))})
                              ]
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:headers_sock)
                          op: assign_op.Equal
                          rhs: 
                            {($ Id.VSub_DollarName '$BALLS_TMP') <'/balls.headers.'> 
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: (C {<_hash>})
                              ) <.sock>
                            }
                          spids: [367]
                        )
                      ]
                    )
                    (command.AndOr
                      ops: [Id.Op_DPipe]
                      children: [
                        (C {<Id.Lit_LBracket '['>} {<-p>} {($ Id.VSub_DollarName '$headers_sock')} 
                          {<Id.Lit_RBracket ']'>}
                        )
                        (C {<mkfifo>} {($ Id.VSub_DollarName '$headers_sock')})
                      ]
                    )
                    (command.Pipeline
                      children: [
                        (command.Subshell
                          child: 
                            (command.Simple
                              words: [{($ Id.VSub_DollarName '$action')}]
                              redirects: [
                                (redir
                                  op: <Id.Redir_Great '3>'>
                                  loc: (redir_loc.Fd fd:3)
                                  arg: {($ Id.VSub_DollarName '$headers_sock')}
                                )
                              ]
                              do_fork: T
                            )
                        )
                        (BraceGroup
                          children: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:headers)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        child: 
                                          (command.Simple
                                            words: [{<cat>}]
                                            redirects: [
                                              (redir
                                                op: <Id.Redir_Less '<'>
                                                loc: (redir_loc.Fd fd:0)
                                                arg: {($ Id.VSub_DollarName '$headers_sock')}
                                              )
                                            ]
                                            do_fork: T
                                          )
                                      )
                                    }
                                  spids: [406]
                                )
                              ]
                            )
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:body)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        child: (C {<cat>} {<->})
                                      )
                                    }
                                  spids: [415]
                                )
                              ]
                            )
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:response)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        child: 
                                          (command.CommandList
                                            children: [
                                              (C {<echo>} {(DQ ($ Id.VSub_DollarName '$headers'))})
                                              (C {<echo>} 
                                                {
                                                  (DQ <'Content-Length: '> 
                                                    (braced_var_sub
                                                      token: <Id.VSub_Name body>
                                                      prefix_op: (Id.VSub_Pound)
                                                    )
                                                  )
                                                }
                                              )
                                              (C {<echo>})
                                              (C {<echo>} {(DQ ($ Id.VSub_DollarName '$body'))})
                                            ]
                                          )
                                      )
                                    }
                                  spids: [424]
                                )
                              ]
                            )
                            (C {<echo>} {(DQ ($ Id.VSub_DollarName '$response'))})
                          ]
                        )
                      ]
                      negated: F
                    )
                    (C {<rm>} {<-f>} {(DQ ($ Id.VSub_DollarName '$headers_sock'))})
                  ]
                  spids: [343 364]
                )
              ]
              else_action: [
                (command.If
                  arms: [
                    (if_arm
                      cond: 
                        (condition.Shell
                          commands: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Binary
                                      op_id: Id.BoolBinary_GlobEqual
                                      left: {(DQ ($ Id.VSub_DollarName '$REQUEST_METHOD'))}
                                      right: {(DQ <HEAD>)}
                                    )
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                        )
                      action: [
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name name:REQUEST_METHOD)
                              op: assign_op.Equal
                              rhs: {<GET>}
                              spids: [502]
                            )
                          ]
                        )
                        (C {<balls> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <route>})
                      ]
                      spids: [482 499]
                    )
                  ]
                  else_action: [
                    (command.Simple
                      words: [{<http> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <status>} {<404>}]
                      redirects: [
                        (redir
                          op: <Id.Redir_GreatAnd '3>&'>
                          loc: (redir_loc.Fd fd:3)
                          arg: {<1>}
                        )
                      ]
                      do_fork: T
                    )
                    (command.Simple
                      words: [
                        {<http> <Id.Lit_Colon ':'> <Id.Lit_Colon ':'> <content_type>}
                        {<'text/plain'>}
                      ]
                      redirects: [
                        (redir
                          op: <Id.Redir_GreatAnd '3>&'>
                          loc: (redir_loc.Fd fd:3)
                          arg: {<1>}
                        )
                      ]
                      do_fork: T
                    )
                    (C {<echo>})
                  ]
                )
                (C {<echo>} 
                  {
                    (DQ <'No route matched '> ($ Id.VSub_DollarName '$REQUEST_METHOD') <' '> 
                      ($ Id.VSub_DollarName '$REQUEST_PATH')
                    )
                  }
                )
                (C {<echo>})
              ]
            )
          ]
        )
    )
  ]
)