You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand the ogen library creates a server that you hook handler methods into that handles alot of the boiler plating for you.
My concern here is that the design of the code makes it very hard to use all the features without using the server in it's entirety.
For my use case, I already have a golang server running, thus I do not need to server struct. The plan here was a slow migration, which would start with generating types from the open api schema, and using the accessory methods with it.
I encounter a problem here, I am able to use the types from the generated code, but the generated code also has useful methods that allow for decoding the request body into the struct and validation and other functions.
I would like to use these without having to use the server, since these are methods of the struct server and further it is not exported, I cannot use these methods.
My sugestion looking at the generated encoding code that is a method of server, it does not need the server anywhere for decoding the request into the struct type, thus would it be possible to create a function that would be exported instead. An example use is below
Problem below
data := &api.XXXRequest{}
// right now this does not work
s := &api.Server{}
request, close, err := s.decodeXXXRequest(r)
// do other things with data here
Suggestion
data := &api.XXXRequest{}
request, close, err := DecodeXXXRequest(r)
// do other things with data here
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As I understand the ogen library creates a server that you hook handler methods into that handles alot of the boiler plating for you.
My concern here is that the design of the code makes it very hard to use all the features without using the server in it's entirety.
For my use case, I already have a golang server running, thus I do not need to
server
struct. The plan here was a slow migration, which would start with generating types from the open api schema, and using the accessory methods with it.I encounter a problem here, I am able to use the types from the generated code, but the generated code also has useful methods that allow for decoding the request body into the struct and validation and other functions.
I would like to use these without having to use the server, since these are methods of the struct
server
and further it is not exported, I cannot use these methods.My sugestion looking at the generated encoding code that is a method of
server
, it does not need theserver
anywhere for decoding the request into the struct type, thus would it be possible to create a function that would be exported instead. An example use is belowProblem below
Suggestion
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions