7
7
"github.com/google/uuid"
8
8
"github.com/tomvodi/limepipes-plugin-api/plugin/v1/file_type"
9
9
"github.com/tomvodi/limepipes/internal/apigen/apimodel"
10
- api_interfaces "github.com/tomvodi/limepipes/internal/apigen/interfaces"
11
10
"github.com/tomvodi/limepipes/internal/common"
12
11
"github.com/tomvodi/limepipes/internal/interfaces"
13
12
"io"
@@ -16,17 +15,17 @@ import (
16
15
"path/filepath"
17
16
)
18
17
19
- type apiHandler struct {
18
+ type Handler struct {
20
19
service interfaces.DataService
21
20
pluginLoader interfaces.PluginLoader
22
21
healthChecker interfaces.HealthChecker
23
22
}
24
23
25
- func (a * apiHandler ) Home (c * gin.Context ) {
24
+ func (a * Handler ) Home (c * gin.Context ) {
26
25
c .Status (http .StatusOK )
27
26
}
28
27
29
- func (a * apiHandler ) Health (c * gin.Context ) {
28
+ func (a * Handler ) Health (c * gin.Context ) {
30
29
handler , err := a .healthChecker .GetCheckHandler ()
31
30
if err != nil {
32
31
httpErrorResponse (c , http .StatusInternalServerError , err )
@@ -37,7 +36,7 @@ func (a *apiHandler) Health(c *gin.Context) {
37
36
handleFunc (c )
38
37
}
39
38
40
- func (a * apiHandler ) ImportFile (c * gin.Context ) {
39
+ func (a * Handler ) ImportFile (c * gin.Context ) {
41
40
iFile , err := c .FormFile ("file" )
42
41
if err != nil {
43
42
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -95,7 +94,7 @@ func (a *apiHandler) ImportFile(c *gin.Context) {
95
94
c .JSON (http .StatusOK , importResponse )
96
95
}
97
96
98
- func (a * apiHandler ) createImportFileInfo (
97
+ func (a * Handler ) createImportFileInfo (
99
98
iFile * multipart.FileHeader ,
100
99
fType file_type.Type ,
101
100
) (* common.ImportFileInfo , error ) {
@@ -118,7 +117,7 @@ func (a *apiHandler) createImportFileInfo(
118
117
return fInfo , nil
119
118
}
120
119
121
- func (a * apiHandler ) importFile (
120
+ func (a * Handler ) importFile (
122
121
fInfo * common.ImportFileInfo ,
123
122
fileExt string ,
124
123
) ([]* apimodel.ImportTune , * apimodel.BasicMusicSet , error ) {
@@ -152,11 +151,11 @@ func handleResponseForError(c *gin.Context, err error) {
152
151
})
153
152
}
154
153
155
- func (a * apiHandler ) Index (c * gin.Context ) {
154
+ func (a * Handler ) Index (c * gin.Context ) {
156
155
c .JSON (http .StatusOK , gin.H {})
157
156
}
158
157
159
- func (a * apiHandler ) CreateTune (c * gin.Context ) {
158
+ func (a * Handler ) CreateTune (c * gin.Context ) {
160
159
var createTune apimodel.CreateTune
161
160
if err := c .ShouldBindJSON (& createTune ); err != nil {
162
161
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -172,7 +171,7 @@ func (a *apiHandler) CreateTune(c *gin.Context) {
172
171
c .JSON (http .StatusOK , tune )
173
172
}
174
173
175
- func (a * apiHandler ) GetTune (c * gin.Context ) {
174
+ func (a * Handler ) GetTune (c * gin.Context ) {
176
175
tuneID , err := uuid .Parse (c .Param ("tuneID" ))
177
176
if err != nil {
178
177
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -188,7 +187,7 @@ func (a *apiHandler) GetTune(c *gin.Context) {
188
187
c .JSON (http .StatusOK , tune )
189
188
}
190
189
191
- func (a * apiHandler ) ListTunes (c * gin.Context ) {
190
+ func (a * Handler ) ListTunes (c * gin.Context ) {
192
191
tunes , err := a .service .Tunes ()
193
192
if err != nil {
194
193
httpErrorResponse (c , http .StatusInternalServerError , err )
@@ -197,7 +196,7 @@ func (a *apiHandler) ListTunes(c *gin.Context) {
197
196
c .JSON (http .StatusOK , tunes )
198
197
}
199
198
200
- func (a * apiHandler ) UpdateTune (c * gin.Context ) {
199
+ func (a * Handler ) UpdateTune (c * gin.Context ) {
201
200
var updateTune apimodel.UpdateTune
202
201
if err := c .ShouldBindJSON (& updateTune ); err != nil {
203
202
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -219,7 +218,7 @@ func (a *apiHandler) UpdateTune(c *gin.Context) {
219
218
c .JSON (http .StatusOK , tune )
220
219
}
221
220
222
- func (a * apiHandler ) DeleteTune (c * gin.Context ) {
221
+ func (a * Handler ) DeleteTune (c * gin.Context ) {
223
222
tuneID , err := uuid .Parse (c .Param ("tuneID" ))
224
223
if err != nil {
225
224
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -234,7 +233,7 @@ func (a *apiHandler) DeleteTune(c *gin.Context) {
234
233
c .Status (http .StatusNoContent )
235
234
}
236
235
237
- func (a * apiHandler ) CreateSet (c * gin.Context ) {
236
+ func (a * Handler ) CreateSet (c * gin.Context ) {
238
237
var createSet apimodel.CreateSet
239
238
240
239
if err := c .ShouldBindJSON (& createSet ); err != nil {
@@ -251,7 +250,7 @@ func (a *apiHandler) CreateSet(c *gin.Context) {
251
250
c .JSON (http .StatusOK , set )
252
251
}
253
252
254
- func (a * apiHandler ) GetSet (c * gin.Context ) {
253
+ func (a * Handler ) GetSet (c * gin.Context ) {
255
254
setID , err := uuid .Parse (c .Param ("setID" ))
256
255
if err != nil {
257
256
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -267,7 +266,7 @@ func (a *apiHandler) GetSet(c *gin.Context) {
267
266
c .JSON (http .StatusOK , set )
268
267
}
269
268
270
- func (a * apiHandler ) ListSets (c * gin.Context ) {
269
+ func (a * Handler ) ListSets (c * gin.Context ) {
271
270
sets , err := a .service .MusicSets ()
272
271
if err != nil {
273
272
httpErrorResponse (c , http .StatusInternalServerError , err )
@@ -276,7 +275,7 @@ func (a *apiHandler) ListSets(c *gin.Context) {
276
275
c .JSON (http .StatusOK , sets )
277
276
}
278
277
279
- func (a * apiHandler ) UpdateSet (c * gin.Context ) {
278
+ func (a * Handler ) UpdateSet (c * gin.Context ) {
280
279
var updateSet apimodel.UpdateSet
281
280
if err := c .ShouldBindJSON (& updateSet ); err != nil {
282
281
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -297,7 +296,7 @@ func (a *apiHandler) UpdateSet(c *gin.Context) {
297
296
c .JSON (http .StatusOK , set )
298
297
}
299
298
300
- func (a * apiHandler ) DeleteSet (c * gin.Context ) {
299
+ func (a * Handler ) DeleteSet (c * gin.Context ) {
301
300
setID , err := uuid .Parse (c .Param ("setID" ))
302
301
if err != nil {
303
302
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -312,7 +311,7 @@ func (a *apiHandler) DeleteSet(c *gin.Context) {
312
311
c .Status (http .StatusNoContent )
313
312
}
314
313
315
- func (a * apiHandler ) AssignTunesToSet (c * gin.Context ) {
314
+ func (a * Handler ) AssignTunesToSet (c * gin.Context ) {
316
315
var tuneIDs []uuid.UUID
317
316
if err := c .ShouldBindJSON (& tuneIDs ); err != nil {
318
317
httpErrorResponse (c , http .StatusBadRequest , err )
@@ -338,8 +337,8 @@ func NewAPIHandler(
338
337
service interfaces.DataService ,
339
338
pluginLoader interfaces.PluginLoader ,
340
339
healthChecker interfaces.HealthChecker ,
341
- ) api_interfaces. ApiHandler {
342
- return & apiHandler {
340
+ ) * Handler {
341
+ return & Handler {
343
342
service : service ,
344
343
pluginLoader : pluginLoader ,
345
344
healthChecker : healthChecker ,
0 commit comments