Git Product home page Git Product logo

mojito's People

Contributors

0skillallluck avatar dependabot[bot] avatar nilathedragon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mojito's Issues

[Enhancement]: Set the HTTP Status Code with context functions

Description

It would be great, if you can set status codes with the helper function in the mojito Context. There is often a reason why you don't want to use 200 and it won't look great if ou need to use ctx.Response().WriteHeader(200).
An proposal would be this:

ctx.JSON(http.StatusOK, any)

Additional Context

No response

Code Snippet

No response

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests reports may be closed without explanation.

[Enhancement]: Add Handler for favicon.ico

Description

Most browsers and other tools expect a favicon to be present on /favicon.ico. To help with this behaviour a utility function to simplify the registration of that endpoint. Optionally a automatic conversion from PNG/JPEG or other image formats to ICO might be a good thing to have.

Additional Context

No response

Code Snippet

package main

import "github.com/go-mojito/mojito"
import "github.com/go-mojito/mojito/handler"

func main() {
  mojito.GET("/", func(ctx mojito.Context) {
    ctx.String("Hello World")
  })
  handler.HandleFavicon()
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests reports may be closed without explanation.

[Bug]: ctx.JSON() not setting json header

Description

If you use in a handler or middleware ctx.JSON(any); there is no Content-Type: application/json Header

How to Reproduce

func main() {
    mojito.GET("/", func(ctx mojito.Context) {
        ctx.JSON("Hello World")
    })

    mojito.ListenAndServe("127.0.0.1:8123")
}

Expected Behavior

Hello World with the Header Content-Type: application/json

Version

v0.0.14

Code Snippet

package main

import "github.com/go-mojito/mojito"

func main() {
  mojito.GET("/", func(ctx mojito.Context) {
    ctx.JSON("Hello World")
  })
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.

[Enhancement]: Add compression middleware

Description

For larger websites compression would be great to have.

The most common compressions(GZIP and Brotli) should be somehow supported to improve website loading speeds.

Additional Context

TODO:

  • Implement new compression middleware
  • Test compression middleware with go-mojito.infinytum.co
  • Update docs to help users using compression

Code Snippet

package main

import "github.com/go-mojito/mojito"
import compression "github.com/go-mojito/extension-compression"

func main() {
  mojito.GET("/", func(ctx mojito.Context) {
    ctx.String("Hello World")
  })
  mojito.WithMiddleware(compression.GZIP)
  mojito.WithMiddleware(compression.Brotli)
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests reports may be closed without explanation.

[Bug]: Middleware must be applied first or won't be called

Description

If middleware is not registered first it won't be called.

How to Reproduce

  1. Create a new mojito project
  2. Register middleware after registering routes
  3. Middleware will not be called

Expected Behavior

Middleware can be applied at any point in time before ListenAndServe is called

Version

v0.0.14

Code Snippet

package main

import "github.com/go-mojito/mojito"

func main() {
  mojito.GET("/", func(ctx mojito.Context) {
    ctx.String("Hello World")
  })
  mojito.WithMiddleware(middleware.Logging)
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.

[Bug]: websocket.Context.Closed() undefined

Description

go run main.go

command-line-arguments

./main.go:9:11: ctx.Closed undefined (type "github.com/go-mojito/mojito/websocket".Context has no field or method Closed)

How to Reproduce

  1. Run the code snippet

Expected Behavior

Able to compile.

Version

0.0.16

Code Snippet

package main

import "github.com/go-mojito/mojito"
import websocket "github.com/go-mojito/mojito/websocket"

func SomeHandler(ctx websocket.Context) {
    for !ctx.Closed() {
        var msg string
        ctx.Receive(&msg)
        ctx.Send(msg)
    }
}

func main() {
  mojito.GET("/", func(ctx mojito.Context) {
    ctx.String("Hello World")
  })
  mojito.GET("/ws", SomeHandler)
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.

[Enhancement]: Auto-Reload at Dev

Description

It would be great to have a helper function or something like that, so you can say the page to reload automaticly if you change a .mojito or .css file while development or debugging

Additional Context

No response

Code Snippet

No response

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests reports may be closed without explanation.

[Enhancement]: Render custom strings

Description

It would be great, to have the possibility to render / show a custom HTML string and not only a path to a specific file.

Additional Context

No response

Code Snippet

package main

import "github.com/go-mojito/mojito"

func main() {
  mojito.GET("/", func(ctx mojito.RendererContext) {
    ctx.Render(`
      <html>
      <body>
      <h1>Hello World</h1>
      </body>
      </html>
`)
  })
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests reports may be closed without explanation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.