Module: Hephaestus::Responses

Included in:
ApplicationController, ValidatesFromYetto
Defined in:
app/controllers/concerns/hephaestus/responses.rb

Instance Method Summary collapse

Instance Method Details

#bad_gatewayObject



81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/controllers/concerns/hephaestus/responses.rb', line 81

def bad_gateway
  render(
    json: {
      errors: [
        {
          message: "Bad Gateway",
        },
      ],
    }.to_json,
    status: :bad_gateway,
  )
end

#bad_requestObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/concerns/hephaestus/responses.rb', line 28

def bad_request
  render(
    json: {
      errors: [
        {
          message: "Bad Request",
        },
      ],
    }.to_json,
    status: :bad_request,
  )
end

#createdObject



19
20
21
22
23
24
25
26
# File 'app/controllers/concerns/hephaestus/responses.rb', line 19

def created
  render(
    json: {
      message: "Created",
    }.to_json,
    status: :created,
  )
end

#forbiddenObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/concerns/hephaestus/responses.rb', line 41

def forbidden
  render(
    json: {
      errors: [
        {
          message: "Forbidden",
        },
      ],
    }.to_json,
    status: :forbidden,
  )
end

#internal_server_errorObject



94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/controllers/concerns/hephaestus/responses.rb', line 94

def internal_server_error
  render(
    json: {
      errors: [
        {
          message: "Internal Server Error",
        },
      ],
    }.to_json,
    status: :internal_server_error,
  )
end

#no_contentObject



6
7
8
# File 'app/controllers/concerns/hephaestus/responses.rb', line 6

def no_content
  head(:no_content)
end

#not_acceptableObject



54
55
56
57
58
59
# File 'app/controllers/concerns/hephaestus/responses.rb', line 54

def not_acceptable
  render(
    json: ::Hephaestus::ErrorSerializer.format("Not Acceptable").to_json,
    status: :not_acceptable,
  )
end

#not_foundObject



61
62
63
64
65
66
# File 'app/controllers/concerns/hephaestus/responses.rb', line 61

def not_found
  render(
    json: ::Hephaestus::ErrorSerializer.format("Not Found").to_json,
    status: :not_found,
  )
end

#okayObject



10
11
12
13
14
15
16
17
# File 'app/controllers/concerns/hephaestus/responses.rb', line 10

def okay
  render(
    json: {
      message: "OK",
    }.to_json,
    status: :ok,
  )
end

#service_unavailable(msg) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/controllers/concerns/hephaestus/responses.rb', line 68

def service_unavailable(msg)
  render(
    json: {
      errors: [
        {
          message: "Service Unavailable: #{msg}",
        },
      ],
    }.to_json,
    status: :service_unavailable,
  )
end