Skip to content

Commit

Permalink
Extracted method
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Meyer committed Apr 14, 2015
1 parent 38dc25b commit 973c014
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ func wire_fail() []interface{} {
return wire_response("fail")
}

func fail_response(message string) string {
response := append(wire_fail(), map[string]string{"message" : message})
func encode_json(response []interface{}) string {
encoded, _ := json.Marshal(response)
return string(encoded)
}

func fail_response(message string) string {
response := append(wire_fail(), map[string]string{"message" : message})
return encode_json(response)
}

func success_response_steps(id string, arguments []capturing_group) string {
arguments_string := build_arguments_string(arguments)
return `["success",[{"id":"` + id + `","args":[` + arguments_string + `]}]]`
Expand All @@ -128,6 +132,5 @@ func success_response_snippet(name string, keyword string) string {

response := append(wire_success(), snippet_text)

encoded, _ := json.Marshal(response)
return string(encoded)
return encode_json(response)
}

0 comments on commit 973c014

Please sign in to comment.