How to create your Golang APIs from now on with v1.22

Sdílet
Vložit
  • čas přidán 16. 06. 2024
  • Since Go 1.22 released you can now build your API services with just the net/http package, without the need for any external packages likes gorilla/mux, fiber or chi.
    So in this video I’ll show you how I’m going to be building my APIs from now on with go 1.22.
    💻 Check the "Complete Backend API in Golang" Course: • Complete Backend API i...
    👉 Join the private community to level up as software engineer: selfmadeengineer.com
    📢 We're building a Discord community, come and join
    / discord
    Hope you liked and thanks for watching!
    #golang #api #backend
    Time Stamps 👇
    00:00:00 Intro
    00:01:08 API server
    00:03:00 Path values from request
    00:03:45 Method based routing
    00:05:53 Middleware
    00:11:21 Subrouting
    Video titles ideas (for the algo):
    What is new in Golang 1.22
    How to build REST API in Golang 1.22
    Create API in Golang 1.22

Komentáře • 35

  • @TannerBarcelos
    @TannerBarcelos Před 2 měsíci +14

    I love the Echo framework, but for a very basic REST API or for learning Go and the stdlib, these new 1.22 updates for http, and Go itself make learning really good. Awesome video. As a TS dev, I am so used to reaching for libraries, but Go is so simple and elegant, you almost don't need to ever reach outside the stdlib 90% of the time. I can see why folks will reach for a router beyond the native one, though, because it definitely does abstract a few things away like creating a new mux for another router, stripping prefixes and defining the method in the route path. Enjoy your content brother, keep it up!

  • @MattRobinsonDev
    @MattRobinsonDev Před 2 měsíci +4

    Another great video Tiago!

  • @liyang-ib6lk
    @liyang-ib6lk Před měsícem +2

    The tutorial explanation is very clear and easy to learn! The style is also good!

  • @prashlovessamosa
    @prashlovessamosa Před 2 měsíci +4

    Thanks for sharing buddy.

  • @goncalofaraujo
    @goncalofaraujo Před 2 měsíci +2

    Very nice and useful tips. Thank you.

  • @Justanotherlurker69
    @Justanotherlurker69 Před 2 měsíci +2

    Nice and clean. Thanks

  • @herminio.machava
    @herminio.machava Před 2 měsíci +4

    Obrigado Tiago por mais um video incrível! Abraço de Moçambique!

  • @langqin
    @langqin Před měsícem

    very helpful!

  • @gabriell7472
    @gabriell7472 Před 2 měsíci +2

    Obrigado amigo! Very helpful :)

  • @saurontrollbrawl
    @saurontrollbrawl Před 2 měsíci +4

    Tnx man!

  • @fadygamilmahrousmasoud5863
    @fadygamilmahrousmasoud5863 Před 2 měsíci +2

    Thank you

  • @afsdab
    @afsdab Před 2 měsíci +3

    Great Video , I'm learning Go and I'm trying to use stdlib before trying any external library, your videos are helping me with this.

  • @marcelofeitoza3918
    @marcelofeitoza3918 Před 2 měsíci +2

    Amazing content, helping a lot

  • @de-is
    @de-is Před 2 měsíci +2

    Again, thanks for the great work. very motivational, and helps me to move forward.
    I hope in your next video you are going to explain the "Functional Options" pattern you have used for "Middleware Chaining". Coz in this video you have just quietly typed it. :)))

  • @solidev7702
    @solidev7702 Před 2 měsíci +2

    Yes man!!!

  • @ferasmnsha5583
    @ferasmnsha5583 Před 2 měsíci +1

    can you please do a tutorial about using redis as a cache write-through in golang

  • @iamhexdd
    @iamhexdd Před 2 dny

    How can i automate documentation for my apis Tiago when using this approach instead of using other web frameworks?

  • @roshanpaudel6352
    @roshanpaudel6352 Před 24 dny +1

    Hi boss, I love your go content. I usually watch you and you use vim/nvim in your vscode with ease. I am a fulltime nvim user and I struggle to navigate around vscode even though using nvim extension. I love the way you navigate around. I looked at the description I couldn't find your github. Would you be able to share your vscode configs. I would love to implement it.
    Thank you for your awesome content.

    • @TiagoTaquelim
      @TiagoTaquelim  Před 24 dny

      Thank you!
      I actually don't use vim. It looks like it because I made it so, but I'm just using the VSCode keybinds, I havent got the need to use VIM because I'm gotten pretty efficient with them.
      Here are the dotfiles: github.com/sikozonpc/dotfiles
      Not sure if they're 100% updated tho.

    • @roshanpaudel6352
      @roshanpaudel6352 Před 23 dny

      @@TiagoTaquelim Thank you so much 😃

  • @Rundik
    @Rundik Před 2 měsíci +1

    If server fails to start it will still print the message that it has started

  • @PhanorColl
    @PhanorColl Před 2 měsíci +3

    for sub-routing, did you change the handler in the server to V1, or left the router, I tried it, if I leave Handler: router, it does not take effect , if I change it fo Handler: v1, it takes effect, how would you handle multiple subrouting?

    • @TiagoTaquelim
      @TiagoTaquelim  Před 2 měsíci +1

      Try to change the endpoint handlers to the v1 the mux if that is not working.
      To handle multiple routing I would do the same as I did but then you need to do what I mention above. You could create an "adminRouter" and all of the admin handlers needed to be from that router.

    • @hsemix
      @hsemix Před 2 měsíci

      @@TiagoTaquelim Do you mean v1.HandleFunc("GET /users/{userID}", handler) coz that didn't work either

    • @liyang-ib6lk
      @liyang-ib6lk Před měsícem +1

      I agree with you there.I ran the code for this video in my golan, but it does not match the results shown in the video. I am using the go version 1.22.1.The problem lies in the sub routing set by v1.I set the port to 8081.When I use curl -H "Authorization: Bearer token" localhost:8081/api/v1/users/23232 . The returned result is 404 page not found.What is the reason for this?

    • @liyang-ib6lk
      @liyang-ib6lk Před měsícem +1

      @@TiagoTaquelim I have found the answer.This way of writing will have the same effect as in the video
      middleWareChain := MiddlewareChain(RequestLogMiddleware, RequestAuthMiddleware)
      childRouter := http.NewServeMux()
      childRouter.Handle("/api/v1/", http.StripPrefix("/api/v1", router))
      server := http.Server{
      Addr: s.addr,
      Handler: middleWareChain(childRouter),
      }

  • @user-pc3hd6sw7g
    @user-pc3hd6sw7g Před 2 měsíci +1

    thanks for your content, but now I need to hardcode the method type? who designs this wtf haha

  • @madmaxdev
    @madmaxdev Před 2 měsíci +1

    What theme is this?