GithubHelp home page GithubHelp logo

martini's People

Contributors

aybabtme avatar baldrailers avatar burntsushi avatar cgarvis avatar codegangsta avatar googollee avatar icholy avatar ioboi avatar jakejscott avatar jamesclonk avatar jeyb avatar jiumx60rus avatar melito avatar mohamedattahri avatar mtojek avatar noonat avatar novemberfoxtrot avatar parkayun avatar prosto-chewey avatar rexk avatar runemadsen avatar shirro avatar shuhei avatar takashi avatar tarrsalah avatar thevisus avatar txgruppi avatar vanackere avatar viniciusfeitosa avatar wils0n avatar

Stargazers

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

Watchers

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

martini's Issues

Martini classic

There should be a super easy default setup for martini. I like to call it classic

Document discrepancies between Middleware handlers and Routing handlers

I probably not understand how Next() works. I wanted to create middleware which creates MongoDB connection dedicated to particular http request so I have to defer connection.Close(). How can I do that?

Finally I stripped my code to almost nothing and this is my result:

func main() {

middleware := func(c martini.Context) {

    defer println(4)

    println(1)

    c.Next()

    println(3)

}

m := martini.Classic()

m.Get("/test", middleware, func() {
println(2)
}

m.Run()
}
[martini] listening on port 3000
[martini] Started GET /test
[martini] Completed 0  in 145.732us
1
3
4
2

Video tour

Create a introductory video tour to have on the landing page

Create a DeferredResponseWriter to handle writes better

The basic concept is that we wan't to be able to rewrite a response if we so please. The default http.ResponseWriter implementation does not handle multiple writes very well, so we should wrap the default implementation into one that defers the actual writing of the response until Commit() is called.

'Get' example returns executable.

package main

import "github.com/codegangsta/martini"

func main() {
  m := martini.Classic()
  m.Get("/", func() string {
    return "Hello world!"
  })
  m.Run()
}

Building, running and then browsing :3000 initiates a download of the built executable (5.3MB). Changing the path to '/test' and browsing :3000/test will return "Hello world!". This is on OSX Mavericks and tested with Go 1.1 and Go 1.2.

Running the default net/http server example on :3000 work just fine.

This is pretty bizarre behavior. Have you seen it before?

Install fails on Windows and Ubuntu

go get github.com/codegangsta/martini
github.com/codegangsta/martini
Dropbox/go/src/github.com/codegangsta/martini/martini.go:94: method r.Handle is not an expression, must be called
Dropbox/go/src/github.com/codegangsta/martini/router.go:58: method route.handle is not an expression, must be called

The last commit was 3302320

Documentation bug?

If a handler returns something, Martini will write the result to the current *http.Request as a string

I think you meant http.ResponseWriter

Panic on middleware validation

I got bit by this. It is unlikely that someone will check it an error when calling use. Panic makes sense in this kind of situation

Allow custom loggers

martini.New() creates it's own logger. It would be nice to be able to initialize Martini with a custom logger.

Trailing Slashes

The Martini router may wish to provide a way to enforce trailing slashes and add them when not present (and vice-versa) so that /stuff/abc-def can be re-directed to /stuff/abc-def/.

Users could set this with a boolean when creating a new Martini instance.

JSON

I need some help with json. I would like to write middleware and be able to create handlers like these:

func jsonHandler() *MyTypeMarshallableToJson {
  return &MyTypeMarshallableToJson{}
}

func jsonWithStatusHandler() (int, *MyTypeMarshallableToJson) {
  return 201, &MyTypeMarshallableToJson{}
}

It would be awesome if I could delegate json/xml formatting to middlewares and only return domain objects in handlers.

Is it even possible? Can I have access to handler's "return"? Maybe Is there another more idiomatic approach?

Issue installing with go get

I was installing martini with go get and this showed up:

/usr/lib/go/src/pkg/github.com/mvader/martini/martini.go:94: method r.Handle is not an expression, must be called
/usr/lib/go/src/pkg/github.com/mvader/martini/router.go:58: method route.handle is not an expression, must be called

I took a look at the code but it looked good to me.

Go version: go version go1.1.2 linux/386

Swagger Integration (Feature Request)

Hi

First of all, nice project. I like it a lot.

Some feature that would make this project even more attractive is support for swagger.

Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.

Website: https://developers.helloreverb.com/swagger/
Example: http://petstore.swagger.wordnik.com/

Swagger is already supported by play-framework, scalatra, django, go-restful.

BR, Rene

method x is not an expression, must be called

I'm getting the following error when I try to go get github.com/codegangsta/martini

# github.com/codegangsta/martini
/usr/lib/go/src/pkg/github.com/codegangsta/martini/martini.go:94: method r.Handle is not an expression, must be called
/usr/lib/go/src/pkg/github.com/codegangsta/martini/router.go:58: method route.handle is not an expression, must be called

I'm new to Go so maybe I'm missing something really obvious...

Thanks!

Params middleware

It would be nice to have a middleware that parsed url params and provide a martini.Params service that other middlewares/actions can use

martini.Static fails serving index.html on Windows

Reproduce by serving martini.Classic() and putting an index.html file in the public directory. Browse http://{host}:{port}/.

Expected martini to serve index.html.

Actually returns an HTTP 404.

Resolve: In static.go (line 29), dir.Open(file) fails as file contains an invalid path: \index.html. Replacing back-slashes with slashes makes it work as expected. This will probably fail on Linux machines, though (right?).

Create a Form handler

The form handler should take a pointer to a struct and attempt to bind PostFormFields to the struct. We can use field tags to do some fancy conversion and presence validation. The handler will then inject the struct into any later handlers.

I imagine it looking something like this:

import "github.com/codegangsta/martini/form"

type BlogPost struct {
  Title string `form:"title,required"`
  Content string `form:"content,required"`
  Author string `form:"author"`
}

m.Post("/blogpost", form.Form(&BlogPost), func(p *BlogPost) string {
  return p.Content
})

Martini ResponseWriter that implements http.Hijack

I'm quite new to Go, so please excuse me if this is just nonesense.

Would it be possible for your responseWriter type to implement http.Hijack? This would allow libraries like this websockets one to work with martini.

I'm not sure if this is something that should be done, I was just trying to write something really quick, came up with an error and found out this was the reason. If this is a silly way to do it feel free to tell me ๐Ÿ˜„

response headers?

Is there a way to set those? I can't find anything in the code to suggest it, but I'm still fairly new to go

custom 404 handler

Martini is great!

I'm just missing the ability to set my own "page not found"-handler if no route matches. That would be great, m'kay.

Cheers :)

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.