forked from go-swagger/go-swagger
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure_simple_to_do_list.go
54 lines (42 loc) · 2.29 KB
/
configure_simple_to_do_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"net/http"
"github.com/go-swagger/go-swagger/errors"
"github.com/go-swagger/go-swagger/httpkit"
"github.com/go-swagger/go-swagger/httpkit/middleware"
"github.com/go-swagger/go-swagger/examples/todo-list/restapi/operations"
"github.com/go-swagger/go-swagger/examples/todo-list/restapi/operations/todos"
)
// This file is safe to edit. Once it exists it will not be overwritten
func configureAPI(api *operations.SimpleToDoListAPI) http.Handler {
// configure the api here
api.ServeError = errors.ServeError
api.JSONConsumer = httpkit.JSONConsumer()
api.JSONProducer = httpkit.JSONProducer()
api.KeyAuth = func(token string) (interface{}, error) {
return nil, errors.NotImplemented("api key auth (key) x-petstore-token from header has not yet been implemented")
}
api.TodosAddOneHandler = todos.AddOneHandlerFunc(func(params todos.AddOneParams, principal interface{}) middleware.Responder {
return middleware.NotImplemented("operation todos.AddOne has not yet been implemented")
})
api.TodosDestroyOneHandler = todos.DestroyOneHandlerFunc(func(params todos.DestroyOneParams, principal interface{}) middleware.Responder {
return middleware.NotImplemented("operation todos.DestroyOne has not yet been implemented")
})
api.TodosFindHandler = todos.FindHandlerFunc(func(params todos.FindParams, principal interface{}) middleware.Responder {
return middleware.NotImplemented("operation todos.Find has not yet been implemented")
})
api.TodosUpdateOneHandler = todos.UpdateOneHandlerFunc(func(params todos.UpdateOneParams, principal interface{}) middleware.Responder {
return middleware.NotImplemented("operation todos.UpdateOne has not yet been implemented")
})
return setupGlobalMiddleware(api.Serve(setupMiddlewares))
}
// The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
// The middleware executes after routing but before authentication, binding and validation
func setupMiddlewares(handler http.Handler) http.Handler {
return handler
}
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
// So this is a good place to plug in a panic handling middleware, logging and metrics
func setupGlobalMiddleware(handler http.Handler) http.Handler {
return handler
}